diff --git a/examples/annotated-skaffold.yaml b/examples/annotated-skaffold.yaml index 4a17d2b0a04..ac9399483eb 100644 --- a/examples/annotated-skaffold.yaml +++ b/examples/annotated-skaffold.yaml @@ -147,7 +147,9 @@ deploy: # releases: # - name: skaffold-helm # chartPath: skaffold-helm - # valuesFilePath: helm-skaffold-values.yaml + # valuesFiles: + # - first-values-file.yaml + # - second-values-file.yaml # values: # image: skaffold-helm # namespace: skaffold diff --git a/examples/helm-deployment/README.adoc b/examples/helm-deployment/README.adoc index a4d94cb3afc..1fd3e17f3d8 100644 --- a/examples/helm-deployment/README.adoc +++ b/examples/helm-deployment/README.adoc @@ -30,6 +30,8 @@ deploy: namespace: skaffold values: image: skaffold-helm + valuesFiles: + - helm-values-file.yaml ``` This part tells skaffold to set the `image` parameter of the values file to the built skaffold-helm image and tag. diff --git a/examples/helm-deployment/skaffold.yaml b/examples/helm-deployment/skaffold.yaml index ecd82eb8efe..6c5ae9febdc 100644 --- a/examples/helm-deployment/skaffold.yaml +++ b/examples/helm-deployment/skaffold.yaml @@ -11,7 +11,8 @@ deploy: - name: skaffold-helm chartPath: skaffold-helm #wait: true - #valuesFilePath: helm-skaffold-values.yaml + #valuesFiles: + #- helm-skaffold-values.yaml values: image: gcr.io/k8s-skaffold/skaffold-helm #recreatePods will pass --recreate-pods to helm upgrade diff --git a/pkg/skaffold/config/transform/transforms.go b/pkg/skaffold/config/transform/transforms.go index 9c81b19b365..f45332103ae 100644 --- a/pkg/skaffold/config/transform/transforms.go +++ b/pkg/skaffold/config/transform/transforms.go @@ -132,6 +132,12 @@ func ToV1Alpha3(vc util.VersionedConfig) (util.VersionedConfig, error) { if err := convert(oldConfig.Deploy, &newDeploy); err != nil { return nil, errors.Wrap(err, "converting deploy config") } + // if the helm deploy config was set, then convert ValueFilePath to ValuesFiles + if oldHelmDeploy := oldConfig.Deploy.DeployType.HelmDeploy; oldHelmDeploy != nil { + for i, oldHelmRelease := range oldHelmDeploy.Releases { + newDeploy.DeployType.HelmDeploy.Releases[i].ValuesFiles = []string{oldHelmRelease.ValuesFilePath} + } + } // convert v1alpha2.Profiles to v1alpha3.Profiles (should be the same) var newProfiles []v1alpha3.Profile diff --git a/pkg/skaffold/deploy/helm.go b/pkg/skaffold/deploy/helm.go index e6eab8af14f..4caccb63ed6 100644 --- a/pkg/skaffold/deploy/helm.go +++ b/pkg/skaffold/deploy/helm.go @@ -79,9 +79,7 @@ func (h *HelmDeployer) Deploy(ctx context.Context, out io.Writer, builds []build func (h *HelmDeployer) Dependencies() ([]string, error) { var deps []string for _, release := range h.Releases { - if release.ValuesFilePath != "" { - deps = append(deps, release.ValuesFilePath) - } + deps = append(deps, release.ValuesFiles...) chartDepsDir := filepath.Join(release.ChartPath, "charts") filepath.Walk(release.ChartPath, func(path string, info os.FileInfo, err error) error { if !info.IsDir() && !strings.HasPrefix(path, chartDepsDir) { @@ -206,8 +204,8 @@ func (h *HelmDeployer) deployRelease(ctx context.Context, out io.Writer, r v1alp } args = append(args, "-f", constants.HelmOverridesFilename) } - if r.ValuesFilePath != "" { - args = append(args, "-f", r.ValuesFilePath) + for _, valuesFile := range r.ValuesFiles { + args = append(args, "-f", valuesFile) } setValues := r.SetValues diff --git a/pkg/skaffold/deploy/helm_test.go b/pkg/skaffold/deploy/helm_test.go index 419c3b1fbe6..99cdcdbc032 100644 --- a/pkg/skaffold/deploy/helm_test.go +++ b/pkg/skaffold/deploy/helm_test.go @@ -491,10 +491,10 @@ func TestExtractChartFilename(t *testing.T) { func TestHelmDependencies(t *testing.T) { var tests = []struct { - description string - files []string - valuesFilePath string - expected func(folder *testutil.TempDir) []string + description string + files []string + valuesFiles []string + expected func(folder *testutil.TempDir) []string }{ { description: "charts dir is excluded", @@ -504,9 +504,9 @@ func TestHelmDependencies(t *testing.T) { }, }, { - description: "values file is included", - files: []string{"Chart.yaml"}, - valuesFilePath: "/folder/values.yaml", + description: "values file is included", + files: []string{"Chart.yaml"}, + valuesFiles: []string{"/folder/values.yaml"}, expected: func(folder *testutil.TempDir) []string { return []string{"/folder/values.yaml", folder.Path("Chart.yaml")} }, @@ -524,12 +524,12 @@ func TestHelmDependencies(t *testing.T) { deployer := NewHelmDeployer(&v1alpha3.HelmDeploy{ Releases: []v1alpha3.HelmRelease{ { - Name: "skaffold-helm", - ChartPath: folder.Root(), - ValuesFilePath: tt.valuesFilePath, - Values: map[string]string{"image": "skaffold-helm"}, - Overrides: map[string]interface{}{"foo": "bar"}, - SetValues: map[string]string{"some.key": "somevalue"}, + Name: "skaffold-helm", + ChartPath: folder.Root(), + ValuesFiles: tt.valuesFiles, + Values: map[string]string{"image": "skaffold-helm"}, + Overrides: map[string]interface{}{"foo": "bar"}, + SetValues: map[string]string{"some.key": "somevalue"}, }, }, }, testKubeContext, testNamespace) diff --git a/pkg/skaffold/schema/v1alpha3/config.go b/pkg/skaffold/schema/v1alpha3/config.go index 8028b52804f..665861826b6 100644 --- a/pkg/skaffold/schema/v1alpha3/config.go +++ b/pkg/skaffold/schema/v1alpha3/config.go @@ -152,7 +152,7 @@ type KustomizeDeploy struct { type HelmRelease struct { Name string `yaml:"name"` ChartPath string `yaml:"chartPath"` - ValuesFilePath string `yaml:"valuesFilePath"` + ValuesFiles []string `yaml:"valuesFiles"` Values map[string]string `yaml:"values,omitempty"` Namespace string `yaml:"namespace"` Version string `yaml:"version"`