Skip to content

Commit

Permalink
Run vals against values files that contain the syntax
Browse files Browse the repository at this point in the history
If we specify ref+ syntax in a values file, run vals against that file.

Signed-off-by: Tom Duffield <tom@chef.io>
  • Loading branch information
tduffield committed Oct 30, 2019
1 parent 78bc481 commit eba3341
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion pkg/state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit eba3341

Please sign in to comment.