Skip to content

Commit 31cf2f1

Browse files
Add repo field to helm release (#5410)
* add ability to specify repo for helm release * update schema
1 parent ba2390d commit 31cf2f1

File tree

5 files changed

+43
-0
lines changed

5 files changed

+43
-0
lines changed

docs/content/en/schemas/v2beta13.json

+6
Original file line numberDiff line numberDiff line change
@@ -1550,6 +1550,11 @@
15501550
"x-intellij-html-description": "specifies whether the chart path is remote, or exists on the host filesystem.",
15511551
"default": "false"
15521552
},
1553+
"repo": {
1554+
"type": "string",
1555+
"description": "specifies the helm repository for remote charts. If present, Skaffold will send `--repo` Helm CLI flag or flags.",
1556+
"x-intellij-html-description": "specifies the helm repository for remote charts. If present, Skaffold will send <code>--repo</code> Helm CLI flag or flags."
1557+
},
15531558
"setFiles": {
15541559
"additionalProperties": {
15551560
"type": "string"
@@ -1621,6 +1626,7 @@
16211626
"skipBuildDependencies",
16221627
"useHelmSecrets",
16231628
"remote",
1629+
"repo",
16241630
"upgradeOnChange",
16251631
"overrides",
16261632
"packaged",

pkg/skaffold/deploy/helm/args.go

+6
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type installOpts struct {
4040
force bool
4141
helmVersion semver.Version
4242
postRenderer string
43+
repo string
4344
}
4445

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

156+
if o.repo != "" {
157+
args = append(args, "--repo")
158+
args = append(args, o.repo)
159+
}
160+
155161
if r.CreateNamespace != nil && *r.CreateNamespace && !o.upgrade {
156162
if o.helmVersion.LT(helm32Version) {
157163
return nil, createNamespaceErr(h.bV.String())

pkg/skaffold/deploy/helm/deploy.go

+1
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,7 @@ func (h *Deployer) deployRelease(ctx context.Context, out io.Writer, releaseName
308308
force: h.forceDeploy,
309309
chartPath: r.ChartPath,
310310
helmVersion: helmVersion,
311+
repo: r.Repo,
311312
}
312313

313314
var installEnv []string

pkg/skaffold/deploy/helm/helm_test.go

+26
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ var testDeployEnvTemplateNamespacedConfig = latest.HelmDeploy{
8989
}},
9090
}
9191

92+
var testDeployConfigRemoteRepo = latest.HelmDeploy{
93+
Releases: []latest.HelmRelease{{
94+
Name: "skaffold-helm",
95+
ChartPath: "examples/test",
96+
ArtifactOverrides: map[string]string{
97+
"image": "skaffold-helm",
98+
},
99+
Overrides: schemautil.HelmOverrides{Values: map[string]interface{}{"foo": "bar"}},
100+
SetValues: map[string]string{
101+
"some.key": "somevalue",
102+
},
103+
Repo: "https://charts.helm.sh/stable",
104+
}},
105+
}
106+
92107
var testDeployConfigTemplated = latest.HelmDeploy{
93108
Releases: []latest.HelmRelease{{
94109
Name: "skaffold-helm",
@@ -591,6 +606,17 @@ func TestHelmDeploy(t *testing.T) {
591606
builds: testBuilds,
592607
expectedNamespaces: []string{"testReleaseFOOBARNamespace"},
593608
},
609+
{
610+
description: "helm3.1 deploy with repo success",
611+
commands: testutil.
612+
CmdRunWithOutput("helm version --client", version31).
613+
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig").
614+
AndRun("helm --kube-context kubecontext dep build examples/test --kubeconfig kubeconfig").
615+
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").
616+
AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig"),
617+
helm: testDeployConfigRemoteRepo,
618+
builds: testBuilds,
619+
},
594620
{
595621
description: "helm3.1 namespaced context deploy success",
596622
commands: testutil.

pkg/skaffold/schema/latest/config.go

+4
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,10 @@ type HelmRelease struct {
731731
// Remote specifies whether the chart path is remote, or exists on the host filesystem.
732732
Remote bool `yaml:"remote,omitempty"`
733733

734+
// Repo specifies the helm repository for remote charts.
735+
// If present, Skaffold will send `--repo` Helm CLI flag or flags.
736+
Repo string `yaml:"repo,omitempty"`
737+
734738
// UpgradeOnChange specifies whether to upgrade helm chart on code changes.
735739
// Default is `true` when helm chart is local (`remote: false`).
736740
// Default is `false` if `remote: true`.

0 commit comments

Comments
 (0)