From 37dda0cf23b419625bb61308e97768b78a4c39eb Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Mon, 8 Jan 2024 12:09:37 -0500 Subject: [PATCH 1/2] fix: helm-deploy-chart-path-template --- integration/run_test.go | 94 ++----------------------- integration/testdata/helm/skaffold.yaml | 8 ++- pkg/skaffold/deploy/helm/helm.go | 5 ++ 3 files changed, 17 insertions(+), 90 deletions(-) diff --git a/integration/run_test.go b/integration/run_test.go index 59d03d6d389..e38d163010f 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -56,95 +56,11 @@ var tests = []struct { targetLog: "Hello world!", }, { - description: "getting-started", - dir: "examples/getting-started", - pods: []string{"getting-started"}, - targetLog: "Hello world!", - }, - { - description: "ko", - dir: "examples/ko", - deployments: []string{"ko"}, - }, - { - description: "nodejs", - dir: "examples/nodejs", - deployments: []string{"node"}, - }, - { - description: "structure-tests", - dir: "examples/structure-tests", - pods: []string{"getting-started"}, - }, - { - description: "custom-tests", - dir: "examples/custom-tests", - pods: []string{"custom-test"}, - }, - { - description: "microservices", - dir: "examples/microservices", - // See https://github.com/GoogleContainerTools/skaffold/issues/2372 - args: []string{"--status-check=false"}, - deployments: []string{"leeroy-app", "leeroy-web"}, - }, - { - description: "multi-config-microservices", - dir: "examples/multi-config-microservices", - deployments: []string{"leeroy-app", "leeroy-web"}, - }, - { - description: "remote-multi-config-microservices", - dir: "examples/remote-multi-config-microservices", - deployments: []string{"leeroy-app", "leeroy-web"}, - }, - { - description: "envTagger", - dir: "examples/tagging-with-environment-variables", - pods: []string{"getting-started"}, - env: []string{"FOO=foo"}, - }, - { - description: "bazel", - dir: "examples/bazel", - pods: []string{"bazel"}, - }, - { - description: "bazel oci", - dir: "testdata/bazel-rules-oci", - deployments: []string{"helloweb"}, - }, - { - description: "bazel oci sub-directory", - dir: "testdata/bazel-rules-oci", - args: []string{"-p", "target-with-package"}, - deployments: []string{"helloweb"}, - }, - { - description: "jib", - dir: "testdata/jib", - deployments: []string{"web"}, - }, - { - description: "jib gradle", - dir: "examples/jib-gradle", - deployments: []string{"web"}, - }, - { - description: "profiles", - dir: "examples/profiles", - args: []string{"-p", "minikube-profile"}, - pods: []string{"hello-service"}, - }, - { - description: "multiple deployers", - dir: "testdata/deploy-multiple", - pods: []string{"deploy-kubectl", "deploy-kustomize"}, - }, - { - description: "custom builder", - dir: "examples/custom", - pods: []string{"getting-started-custom"}, + description: "helm templating charPath", + dir: "testdata/helm", + args: []string{"-p", "helm-templating-charPath"}, + deployments: []string{"skaffold-helm"}, + env: []string{"FOO=skaffold-helm"}, }, // TODO(#8811): Enable this test when issue is solve. // { diff --git a/integration/testdata/helm/skaffold.yaml b/integration/testdata/helm/skaffold.yaml index 8dc91c2bc09..aa0e5fe68e9 100644 --- a/integration/testdata/helm/skaffold.yaml +++ b/integration/testdata/helm/skaffold.yaml @@ -43,4 +43,10 @@ profiles: releases: # seed test namespace in the release name. - name: skaffold-helm-{{.TEST_NS}} - chartPath: skaffold-helm \ No newline at end of file + chartPath: skaffold-helm +- name: helm-templating-charPath + deploy: + helm: + releases: + - name: skaffold-helm + chartPath: '{{.FOO}}' \ No newline at end of file diff --git a/pkg/skaffold/deploy/helm/helm.go b/pkg/skaffold/deploy/helm/helm.go index 99dca27ec4c..89c74acebfa 100644 --- a/pkg/skaffold/deploy/helm/helm.go +++ b/pkg/skaffold/deploy/helm/helm.go @@ -276,6 +276,11 @@ func (h *Deployer) Deploy(ctx context.Context, out io.Writer, builds []graph.Art if err != nil { return helm.UserErr(fmt.Sprintf("cannot expand repo %q", r.Repo), err) } + r.ChartPath, err = util.ExpandEnvTemplateOrFail(r.ChartPath, nil) + if err != nil { + return helm.UserErr(fmt.Sprintf("cannot expand chart path %q", r.ChartPath), err) + } + m, results, err := h.deployRelease(ctx, out, releaseName, r, builds, h.bV, chartVersion, repo) if err != nil { return helm.UserErr(fmt.Sprintf("deploying %q", releaseName), err) From 4b7a89ac198b46e6dbb41846de74a7e79c24cc04 Mon Sep 17 00:00:00 2001 From: ericzzzzzzz <102683393+ericzzzzzzz@users.noreply.github.com> Date: Mon, 8 Jan 2024 12:14:33 -0500 Subject: [PATCH 2/2] chore: add tests back --- integration/run_test.go | 91 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/integration/run_test.go b/integration/run_test.go index e38d163010f..e877ee7b03d 100644 --- a/integration/run_test.go +++ b/integration/run_test.go @@ -55,6 +55,97 @@ var tests = []struct { pods: []string{"empty-dir"}, targetLog: "Hello world!", }, + { + description: "getting-started", + dir: "examples/getting-started", + pods: []string{"getting-started"}, + targetLog: "Hello world!", + }, + { + description: "ko", + dir: "examples/ko", + deployments: []string{"ko"}, + }, + { + description: "nodejs", + dir: "examples/nodejs", + deployments: []string{"node"}, + }, + { + description: "structure-tests", + dir: "examples/structure-tests", + pods: []string{"getting-started"}, + }, + { + description: "custom-tests", + dir: "examples/custom-tests", + pods: []string{"custom-test"}, + }, + { + description: "microservices", + dir: "examples/microservices", + // See https://github.com/GoogleContainerTools/skaffold/issues/2372 + args: []string{"--status-check=false"}, + deployments: []string{"leeroy-app", "leeroy-web"}, + }, + { + description: "multi-config-microservices", + dir: "examples/multi-config-microservices", + deployments: []string{"leeroy-app", "leeroy-web"}, + }, + { + description: "remote-multi-config-microservices", + dir: "examples/remote-multi-config-microservices", + deployments: []string{"leeroy-app", "leeroy-web"}, + }, + { + description: "envTagger", + dir: "examples/tagging-with-environment-variables", + pods: []string{"getting-started"}, + env: []string{"FOO=foo"}, + }, + { + description: "bazel", + dir: "examples/bazel", + pods: []string{"bazel"}, + }, + { + description: "bazel oci", + dir: "testdata/bazel-rules-oci", + deployments: []string{"helloweb"}, + }, + { + description: "bazel oci sub-directory", + dir: "testdata/bazel-rules-oci", + args: []string{"-p", "target-with-package"}, + deployments: []string{"helloweb"}, + }, + { + description: "jib", + dir: "testdata/jib", + deployments: []string{"web"}, + }, + { + description: "jib gradle", + dir: "examples/jib-gradle", + deployments: []string{"web"}, + }, + { + description: "profiles", + dir: "examples/profiles", + args: []string{"-p", "minikube-profile"}, + pods: []string{"hello-service"}, + }, + { + description: "multiple deployers", + dir: "testdata/deploy-multiple", + pods: []string{"deploy-kubectl", "deploy-kustomize"}, + }, + { + description: "custom builder", + dir: "examples/custom", + pods: []string{"getting-started-custom"}, + }, { description: "helm templating charPath", dir: "testdata/helm",