diff --git a/pkg/skaffold/deploy/helm/helm_test.go b/pkg/skaffold/deploy/helm/helm_test.go index efb7e31f830..702984d7c81 100644 --- a/pkg/skaffold/deploy/helm/helm_test.go +++ b/pkg/skaffold/deploy/helm/helm_test.go @@ -89,6 +89,17 @@ var testDeployEnvTemplateNamespacedConfig = latest.LegacyHelmDeploy{ }}, } +var testDeployWithTemplatedChartPath = latest.LegacyHelmDeploy{ + Releases: []latest.HelmRelease{{ + Name: "skaffold-helm", + ChartPath: "examples/{{.FOO}}", + Overrides: schemautil.HelmOverrides{Values: map[string]interface{}{"foo": "bar"}}, + SetValues: map[string]string{ + "some.key": "somevalue", + }, + }}, +} + var testDeployConfigRemoteRepo = latest.LegacyHelmDeploy{ Releases: []latest.HelmRelease{{ Name: "skaffold-helm", @@ -1212,6 +1223,15 @@ func TestHelmRender(t *testing.T) { helm: testDeployWithTemplatedName, builds: testBuilds, }, + { + description: "render with templated chart path", + shouldErr: false, + commands: testutil. + CmdRun("helm --kube-context kubecontext dep build examples/FOOBAR --kubeconfig kubeconfig"). + AndRun("helm --kube-context kubecontext template skaffold-helm examples/FOOBAR --post-renderer SKAFFOLD-BINARY --set some.key=somevalue --kubeconfig kubeconfig"), + helm: testDeployWithTemplatedChartPath, + builds: testBuilds, + }, { description: "render with namespace", shouldErr: false, diff --git a/pkg/skaffold/render/renderer/helm/helm.go b/pkg/skaffold/render/renderer/helm/helm.go index f473dd29beb..747b77de739 100644 --- a/pkg/skaffold/render/renderer/helm/helm.go +++ b/pkg/skaffold/render/renderer/helm/helm.go @@ -125,6 +125,11 @@ func (h Helm) generateHelmManifests(ctx context.Context, builds []graph.Artifact return nil, helm.UserErr(fmt.Sprintf("cannot expand release name %q", release.Name), err) } + release.ChartPath, err = sUtil.ExpandEnvTemplateOrFail(release.ChartPath, nil) + if err != nil { + return nil, helm.UserErr(fmt.Sprintf("cannot expand chart path %q", release.ChartPath), err) + } + args := []string{"template", releaseName, helm.ChartSource(release)} args = append(args, postRendererArgs...) if release.Packaged == nil && release.Version != "" {