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 01:41:39 +01:00 committed by GitHub
parent 9e4bc6e7fc
commit eb8ab54865
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View File

@ -224,6 +224,9 @@ helmfiles:
# The nested-state file is locally checked-out along with the remote directory containing it.
# Therefore all the local paths in the file are resolved relative to the file
path: git::https://github.com/cloudposse/helmfiles.git@releases/kiam.yaml?ref=0.40.0
# If set to "Error", return an error when a subhelmfile points to a
# non-existent path. The default behavior is to print a warning and continue.
missingFileHandler: Error
#
# Advanced Configuration: Environments

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 {