Optionally error when subhelmfiles do not exist (#1245)

This prevents typos in helmfiles from silently preventing operations
from running. The default behavior is to print a warning, to preserve
backwards compatibility.
This commit is contained in:
Craig Furman
2020-05-12 09:41:39 +09:00
committed by GitHub
parent 9e4bc6e7fc
commit eb8ab54865
2 changed files with 13 additions and 0 deletions
+10
View File
@@ -73,6 +73,11 @@ type HelmState struct {
runner helmexec.Runner
valsRuntime vals.Evaluator
// If set to "Error", return an error when a subhelmfile points to a
// non-existent path. The default behavior is to print a warning. Note the
// differing default compared to other MissingFileHandlers.
MissingFileHandler string `yaml:"missingFileHandler"`
}
// SubHelmfileSpec defines the subhelmfile path and options
@@ -1801,6 +1806,11 @@ func (st *HelmState) ExpandedHelmfiles() ([]SubHelmfileSpec, error) {
return nil, err
}
if len(matches) == 0 {
err := fmt.Errorf("no matches for path: %s", hf.Path)
if st.MissingFileHandler == "Error" {
return nil, err
}
fmt.Println(err)
continue
}
for _, match := range matches {