mirror of
https://github.com/helmfile/helmfile.git
synced 2026-10-05 20:44:37 +02:00
Run vals against values files that contain the syntax (#920)
If we specify ref+ syntax in a values file, run vals against that file. Signed-off-by: Tom Duffield <tom@chef.io>
This commit is contained in:
committed by
KUOKA Yusuke
parent
78bc481675
commit
464e6bc782
+27
-1
@@ -1542,7 +1542,33 @@ func (st *HelmState) flagsForLint(helm helmexec.Interface, release *ReleaseSpec,
|
||||
|
||||
func (st *HelmState) RenderValuesFileToBytes(path string) ([]byte, error) {
|
||||
r := tmpl.NewFileRenderer(st.readFile, filepath.Dir(path), st.valuesFileTemplateData())
|
||||
return r.RenderToBytes(path)
|
||||
rawBytes, err := r.RenderToBytes(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If 'ref+.*' exists in file, run vals against the file
|
||||
match, err := regexp.Match("ref\\+.*", rawBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if match {
|
||||
var rawYaml map[string]interface{}
|
||||
|
||||
if err := yaml.Unmarshal(rawBytes, &rawYaml); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
parsedYaml, err := st.valsRuntime.Eval(rawYaml)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return yaml.Marshal(parsedYaml)
|
||||
}
|
||||
|
||||
return rawBytes, nil
|
||||
}
|
||||
|
||||
func (st *HelmState) storage() *Storage {
|
||||
|
||||
Reference in New Issue
Block a user