From 39bc28c23fca6bd9e2db58fe42325b5a48aa555c Mon Sep 17 00:00:00 2001 From: Hung Tran Duc Date: Thu, 13 Dec 2018 16:07:50 +0700 Subject: [PATCH] feat: configurable common path prefix for values files (#408) Removes duplicated declaration path for cleaner helmfile, for example, this configuration. ``` - chart: projectABC name: {{ .Environment.Name }}-projectABC namespace: abc version: {{ .Environment.Values.projectABC.chart.version }} valuesPathPrefix: ../values/{{ .Environment.Name }}/ values: - common.yaml - project-abc.yaml - platform.yaml - ... secrets: - secrets.yaml ``` --- state/state.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/state/state.go b/state/state.go index b1e4c7bd..04cccfa7 100644 --- a/state/state.go +++ b/state/state.go @@ -109,6 +109,8 @@ type ReleaseSpec struct { // The 'env' section is not really necessary any longer, as 'set' would now provide the same functionality EnvValues []SetValue `yaml:"env"` + ValuesPathPrefix string `yaml:"valuesPathPrefix"` + // generatedValues are values that need cleaned up on exit generatedValues []string } @@ -1091,7 +1093,8 @@ func (state *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, release for _, value := range release.Values { switch typedValue := value.(type) { case string: - path := state.normalizePath(typedValue) + path := state.normalizePath(release.ValuesPathPrefix + typedValue) + if _, err := os.Stat(path); os.IsNotExist(err) { return nil, err } @@ -1129,7 +1132,7 @@ func (state *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, release } } for _, value := range release.Secrets { - path := state.normalizePath(value) + path := state.normalizePath(release.ValuesPathPrefix + value) if _, err := os.Stat(path); os.IsNotExist(err) { return nil, err }