Skip to content

Commit

Permalink
Add repo field to helm release (#5410)
Browse files Browse the repository at this point in the history
* add ability to specify repo for helm release

* update schema
  • Loading branch information
bobby-richard authored Mar 3, 2021
1 parent ba2390d commit 31cf2f1
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/content/en/schemas/v2beta13.json
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,11 @@
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem.",
"default": "false"
},
"repo": {
"type": "string",
"description": "specifies the helm repository for remote charts. If present, Skaffold will send `--repo` Helm CLI flag or flags.",
"x-intellij-html-description": "specifies the helm repository for remote charts. If present, Skaffold will send <code>--repo</code> Helm CLI flag or flags."
},
"setFiles": {
"additionalProperties": {
"type": "string"
Expand Down Expand Up @@ -1621,6 +1626,7 @@
"skipBuildDependencies",
"useHelmSecrets",
"remote",
"repo",
"upgradeOnChange",
"overrides",
"packaged",
Expand Down
6 changes: 6 additions & 0 deletions pkg/skaffold/deploy/helm/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type installOpts struct {
force bool
helmVersion semver.Version
postRenderer string
repo string
}

// constructOverrideArgs creates the command line arguments for overrides
Expand Down Expand Up @@ -152,6 +153,11 @@ func (h *Deployer) installArgs(r latest.HelmRelease, builds []build.Artifact, va
args = append(args, "--namespace", o.namespace)
}

if o.repo != "" {
args = append(args, "--repo")
args = append(args, o.repo)
}

if r.CreateNamespace != nil && *r.CreateNamespace && !o.upgrade {
if o.helmVersion.LT(helm32Version) {
return nil, createNamespaceErr(h.bV.String())
Expand Down
1 change: 1 addition & 0 deletions pkg/skaffold/deploy/helm/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ func (h *Deployer) deployRelease(ctx context.Context, out io.Writer, releaseName
force: h.forceDeploy,
chartPath: r.ChartPath,
helmVersion: helmVersion,
repo: r.Repo,
}

var installEnv []string
Expand Down
26 changes: 26 additions & 0 deletions pkg/skaffold/deploy/helm/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,21 @@ var testDeployEnvTemplateNamespacedConfig = latest.HelmDeploy{
}},
}

var testDeployConfigRemoteRepo = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm",
ChartPath: "examples/test",
ArtifactOverrides: map[string]string{
"image": "skaffold-helm",
},
Overrides: schemautil.HelmOverrides{Values: map[string]interface{}{"foo": "bar"}},
SetValues: map[string]string{
"some.key": "somevalue",
},
Repo: "https://charts.helm.sh/stable",
}},
}

var testDeployConfigTemplated = latest.HelmDeploy{
Releases: []latest.HelmRelease{{
Name: "skaffold-helm",
Expand Down Expand Up @@ -591,6 +606,17 @@ func TestHelmDeploy(t *testing.T) {
builds: testBuilds,
expectedNamespaces: []string{"testReleaseFOOBARNamespace"},
},
{
description: "helm3.1 deploy with repo success",
commands: testutil.
CmdRunWithOutput("helm version --client", version31).
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig").
AndRun("helm --kube-context kubecontext dep build examples/test --kubeconfig kubeconfig").
AndRun("helm --kube-context kubecontext upgrade skaffold-helm examples/test --repo https://charts.helm.sh/stable -f skaffold-overrides.yaml --set-string image=docker.io:5000/skaffold-helm:3605e7bc17cf46e53f4d81c4cbc24e5b4c495184 --set some.key=somevalue --kubeconfig kubeconfig").
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig"),
helm: testDeployConfigRemoteRepo,
builds: testBuilds,
},
{
description: "helm3.1 namespaced context deploy success",
commands: testutil.
Expand Down
4 changes: 4 additions & 0 deletions pkg/skaffold/schema/latest/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,10 @@ type HelmRelease struct {
// Remote specifies whether the chart path is remote, or exists on the host filesystem.
Remote bool `yaml:"remote,omitempty"`

// Repo specifies the helm repository for remote charts.
// If present, Skaffold will send `--repo` Helm CLI flag or flags.
Repo string `yaml:"repo,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`.
Expand Down

0 comments on commit 31cf2f1

Please sign in to comment.