Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple helm values files #985

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion examples/annotated-skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions examples/helm-deployment/README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion examples/helm-deployment/skaffold.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/skaffold/config/transform/transforms.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 3 additions & 5 deletions pkg/skaffold/deploy/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions pkg/skaffold/deploy/helm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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")}
},
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/skaffold/schema/v1alpha3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down