Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remote helm charts should not be upgraded by default #3274

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,34 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates
if !isInstalled {
args = append(args, "install", "--name", releaseName)
args = append(args, h.Flags.Install...)
} else if !h.shouldUpgradeOnChange(r) {
logrus.Infof("Release %s already installed...\n", releaseName)
return []Artifact{}, nil
} else {
args = append(args, "upgrade", releaseName)
args = append(args, h.Flags.Upgrade...)
if h.forceDeploy {
args = append(args, "--force")

dahovey marked this conversation as resolved.
Show resolved Hide resolved
var shouldUpgrade bool
if r.UpgradeOnChange != nil {
shouldUpgrade = *r.UpgradeOnChange

if !shouldUpgrade {
logrus.Infof("Release %s already installed...\n", releaseName)
}
} else {
shouldUpgrade = !r.Remote

if !shouldUpgrade {
logrus.Infof("Release %s not upgraded since remote (see `upgradeOnChange`)...\n", releaseName)
}
}
if r.RecreatePods {
args = append(args, "--recreate-pods")

if shouldUpgrade {
args = append(args, "upgrade", releaseName)
args = append(args, h.Flags.Upgrade...)
if h.forceDeploy {
args = append(args, "--force")
}
if r.RecreatePods {
args = append(args, "--recreate-pods")
}
} else {
return []Artifact{}, nil
}
}

Expand Down Expand Up @@ -546,11 +563,3 @@ func expandPaths(paths []string) []string {

return paths
}

func (h *HelmDeployer) shouldUpgradeOnChange(r latest.HelmRelease) bool {
if r.UpgradeOnChange != nil {
return *r.UpgradeOnChange
}

return !r.Remote
}
32 changes: 0 additions & 32 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -940,38 +940,6 @@ func TestGetSetFileValues(t *testing.T) {
}
}

func TestShouldUpgradeOnChange(t *testing.T) {
trueBool := true
tests := []struct {
description string
input latest.HelmRelease
expected bool
}{
{
description: "Default `UpgradeOnChange: false` when `Remote: true`",
input: latest.HelmRelease{Remote: true, UpgradeOnChange: nil},
expected: false,
},
{
description: "Default `UpgradeOnChange: true` when `Remote: false`",
input: latest.HelmRelease{Remote: false, UpgradeOnChange: nil},
expected: true,
},
{
description: "Uses upgradeOnChange value regardless of Remote value",
input: latest.HelmRelease{Remote: true, UpgradeOnChange: &trueBool},
expected: true,
},
}
for _, test := range tests {
testutil.Run(t, test.description, func(t *testutil.T) {
deployer := NewHelmDeployer(&runcontext.RunContext{})

t.CheckDeepEqual(test.expected, deployer.shouldUpgradeOnChange(test.input))
})
}
}

func makeRunContext(deploy latest.HelmDeploy, force bool) *runcontext.RunContext {
pipeline := latest.Pipeline{}
pipeline.Deploy.DeployType.HelmDeploy = &deploy
Expand Down