diff --git a/pkg/skaffold/deploy/helm/deploy.go b/pkg/skaffold/deploy/helm/deploy.go index 67eea026bd3..e246a50af43 100644 --- a/pkg/skaffold/deploy/helm/deploy.go +++ b/pkg/skaffold/deploy/helm/deploy.go @@ -76,6 +76,7 @@ type Deployer struct { kubeContext string kubeConfig string namespace string + configFile string // packaging temporary directory, used for predictable test output pkgTmpDir string @@ -106,6 +107,7 @@ func NewDeployer(cfg kubectl.Config, labels map[string]string) (*Deployer, error kubeConfig: cfg.GetKubeConfig(), namespace: cfg.GetKubeNamespace(), forceDeploy: cfg.ForceDeploy(), + configFile: cfg.ConfigurationFile(), labels: labels, bV: hv, enableDebug: cfg.Mode() == config.RunModes.Debug, @@ -346,6 +348,7 @@ func (h *Deployer) deployRelease(ctx context.Context, out io.Writer, r latest.He // need to include current environment, specifically for HOME to lookup ~/.kube/config env := util.EnvSliceToMap(util.OSEnviron(), "=") env["SKAFFOLD_CMDLINE"] = shell.Join(cmdLine...) + env["SKAFFOLD_FILENAME"] = h.configFile installEnv = util.EnvMapToSlice(env, "=") } diff --git a/pkg/skaffold/deploy/helm/helm_test.go b/pkg/skaffold/deploy/helm/helm_test.go index 26132197a36..f2340a4bdb9 100644 --- a/pkg/skaffold/deploy/helm/helm_test.go +++ b/pkg/skaffold/deploy/helm/helm_test.go @@ -890,7 +890,8 @@ func TestHelmDeploy(t *testing.T) { 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 --post-renderer SKAFFOLD-BINARY examples/test -f skaffold-overrides.yaml --set-string image=docker.io:5000/skaffold-helm:3605e7bc17cf46e53f4d81c4cbc24e5b4c495184 --set some.key=somevalue --kubeconfig kubeconfig"). + AndRunEnv("helm --kube-context kubecontext upgrade skaffold-helm --post-renderer SKAFFOLD-BINARY examples/test -f skaffold-overrides.yaml --set-string image=docker.io:5000/skaffold-helm:3605e7bc17cf46e53f4d81c4cbc24e5b4c495184 --set some.key=somevalue --kubeconfig kubeconfig", + []string{"SKAFFOLD_FILENAME=test.yaml"}). AndRun("helm --kube-context kubecontext get all skaffold-helm --kubeconfig kubeconfig"), helm: testDeployConfig, builds: testBuilds, @@ -938,9 +939,10 @@ func TestHelmDeploy(t *testing.T) { t.Override(&osExecutable, func() (string, error) { return "SKAFFOLD-BINARY", nil }) deployer, err := NewDeployer(&helmConfig{ - helm: test.helm, - namespace: test.namespace, - force: test.force, + helm: test.helm, + namespace: test.namespace, + force: test.force, + configFile: "test.yaml", }, nil) t.RequireNoError(err) @@ -1413,12 +1415,14 @@ type helmConfig struct { namespace string force bool helm latest.HelmDeploy + configFile string } -func (c *helmConfig) ForceDeploy() bool { return c.force } -func (c *helmConfig) GetKubeConfig() string { return kubectl.TestKubeConfig } -func (c *helmConfig) GetKubeContext() string { return kubectl.TestKubeContext } -func (c *helmConfig) GetKubeNamespace() string { return c.namespace } +func (c *helmConfig) ForceDeploy() bool { return c.force } +func (c *helmConfig) GetKubeConfig() string { return kubectl.TestKubeConfig } +func (c *helmConfig) GetKubeContext() string { return kubectl.TestKubeContext } +func (c *helmConfig) GetKubeNamespace() string { return c.namespace } +func (c *helmConfig) ConfigurationFile() string { return c.configFile } func (c *helmConfig) Pipeline() latest.Pipeline { var pipeline latest.Pipeline pipeline.Deploy.DeployType.HelmDeploy = &c.helm diff --git a/pkg/skaffold/deploy/types/types.go b/pkg/skaffold/deploy/types/types.go index 98b681aaa65..6bd0c4696cf 100644 --- a/pkg/skaffold/deploy/types/types.go +++ b/pkg/skaffold/deploy/types/types.go @@ -29,6 +29,7 @@ type Config interface { Pipeline() latest.Pipeline GetWorkingDir() string GlobalConfig() string + ConfigurationFile() string DefaultRepo() *string SkipRender() bool }