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 9 commits
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
14 changes: 10 additions & 4 deletions docs/content/en/schemas/v2alpha4.json
Original file line number Diff line number Diff line change
Expand Up @@ -1214,8 +1214,8 @@
},
"remote": {
"type": "boolean",
"description": "specifies whether the chart path is remote, or exists on the host filesystem. `remote: true` implies `skipBuildDependencies: true`.",
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem. <code>remote: true</code> implies <code>skipBuildDependencies: true</code>.",
"description": "specifies whether the chart path is remote, or exists on the host filesystem.",
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem.",
"default": "false"
},
"setFiles": {
Expand Down Expand Up @@ -1247,10 +1247,15 @@
},
"skipBuildDependencies": {
"type": "boolean",
"description": "should build dependencies be skipped.",
"x-intellij-html-description": "should build dependencies be skipped.",
"description": "should build dependencies be skipped. Ignored when `remote: true`.",
"x-intellij-html-description": "should build dependencies be skipped. Ignored when <code>remote: true</code>.",
"default": "false"
},
"upgradeOnChange": {
"type": "boolean",
"description": "specifies whether to upgrade helm chart on code changes. Default is `true` when helm chart is local (`remote: false`). Default is `false` if `remote: true`.",
"x-intellij-html-description": "specifies whether to upgrade helm chart on code changes. Default is <code>true</code> when helm chart is local (<code>remote: false</code>). Default is <code>false</code> if <code>remote: true</code>."
},
"useHelmSecrets": {
"type": "boolean",
"description": "instructs skaffold to use secrets plugin on deployment.",
Expand Down Expand Up @@ -1302,6 +1307,7 @@
"skipBuildDependencies",
"useHelmSecrets",
"remote",
"upgradeOnChange",
"overrides",
"packaged",
"imageStrategy"
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5a
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1 h1:Xye71clBPdm5HgqGwUkwhbynsUJZhDbS20FvLhQ2izg=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-containerregistry v0.0.0-20191018211754-b77a90c667af/go.mod h1:9kIomAeXUmwhqeYS2zoEuQ0sc2GOVmNW7t3y9aNQL1o=
github.com/google/go-containerregistry v0.0.0-20191218175032-34fb8ff33bed h1:0AwV9UBwwKPKrfpTYLOKr8ymevanUxrsSEkAo0uU9aA=
Expand Down Expand Up @@ -735,6 +736,7 @@ golang.org/x/tools v0.0.0-20191213032237-7093a17b0467/go.mod h1:b+2E5dAYhXwXZwtn
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
Expand Down
12 changes: 10 additions & 2 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,18 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r lates
}

var args []string
if !isInstalled {

switch {
case !isInstalled:
args = append(args, "install", "--name", releaseName)
args = append(args, h.Flags.Install...)
} else {
case r.UpgradeOnChange != nil && !*r.UpgradeOnChange:
logrus.Infof("Release %s already installed...", releaseName)
return []Artifact{}, nil
case r.UpgradeOnChange == nil && r.Remote:
logrus.Infof("Release %s not upgraded as it is remote...", releaseName)
return []Artifact{}, nil
default:
args = append(args, "upgrade", releaseName)
args = append(args, h.Flags.Upgrade...)
if h.forceDeploy {
Expand Down
17 changes: 17 additions & 0 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,15 @@ var testDeployRemoteChart = latest.HelmDeploy{
}},
}

var upgradeOnChangeFalse = false
var testDeployUpgradeOnChange = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm-upgradeOnChange",
ChartPath: "examples/test",
UpgradeOnChange: &upgradeOnChangeFalse,
}},
}

var testDeployWithoutTags = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm",
Expand Down Expand Up @@ -369,6 +378,14 @@ func TestHelmDeploy(t *testing.T) {
runContext: makeRunContext(testDeploySkipBuildDependencies, false),
builds: testBuilds,
},
{
description: "deploy success when `upgradeOnChange: false` and does not upgrade",
commands: &MockHelm{
installResult: fmt.Errorf("should not have called install"),
upgradeResult: fmt.Errorf("should not have called upgrade"),
},
runContext: makeRunContext(testDeployUpgradeOnChange, false),
},
{
description: "deploy error remote chart without skipBuildDependencies",
commands: &MockHelm{
Expand Down
7 changes: 6 additions & 1 deletion pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,15 +504,20 @@ type HelmRelease struct {
RecreatePods bool `yaml:"recreatePods,omitempty"`

// SkipBuildDependencies should build dependencies be skipped.
// Ignored when `remote: true`.
SkipBuildDependencies bool `yaml:"skipBuildDependencies,omitempty"`

// UseHelmSecrets instructs skaffold to use secrets plugin on deployment.
UseHelmSecrets bool `yaml:"useHelmSecrets,omitempty"`

// Remote specifies whether the chart path is remote, or exists on the host filesystem.
// `remote: true` implies `skipBuildDependencies: true`.
Remote bool `yaml:"remote,omitempty"`

// UpgradeOnChange specifies whether to upgrade helm chart on code changes.
// Default is `true` when helm chart is local (`remote: false`).
// Default is `false` if `remote: true`.
UpgradeOnChange *bool `yaml:"upgradeOnChange,omitempty"`

// Overrides are key-value pairs.
// If present, Skaffold will build a Helm `values` file that overrides
// the original and use it to call Helm CLI (`--f` flag).
Expand Down