Skip to content

Commit

Permalink
fix missingFileHandler (#440)
Browse files Browse the repository at this point in the history
- Fix panics when `missingFileHandler` is not defined
- Fix `missingFileHandler: Error` had been writing errors at the Warn level
- Add `Info` and `Debug` as valid values

Ref #439 (comment)
  • Loading branch information
mumoshu authored Jan 22, 2019
1 parent 171eacf commit 5f52f96
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 2 additions & 0 deletions docs/writing-helmfile.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ templates:
chart: stable/{{`{{ .Release.Name }}`}}
namespace: kube-system
# This prevents helmfile exiting when it encounters a missing file
# Valid values are "Error", "Warn", "Info", "Debug". The default is "Error"
# Use "Debug" to make missing files errors invisible at the default log level(--log-level=INFO)
missingFileHandler: Warn
values:
- config/{{`{{ .Release.Name }}`}}/values.yaml
Expand Down
20 changes: 16 additions & 4 deletions state/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,11 +1104,17 @@ func (st *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, release *R
path := st.normalizePath(release.ValuesPathPrefix + typedValue)

if _, err := os.Stat(path); os.IsNotExist(err) {
if release.MissingFileHandler == nil && *release.MissingFileHandler == "Error" {
if release.MissingFileHandler == nil || *release.MissingFileHandler == "Error" {
return nil, err
} else {
} else if *release.MissingFileHandler == "Warn" {
st.logger.Warnf("skipping missing values file \"%s\"", path)
continue
} else if *release.MissingFileHandler == "Info" {
st.logger.Infof("skipping missing values file \"%s\"", path)
continue
} else {
st.logger.Debugf("skipping missing values file \"%s\"", path)
continue
}
}

Expand Down Expand Up @@ -1148,11 +1154,17 @@ func (st *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, release *R
for _, value := range release.Secrets {
path := st.normalizePath(release.ValuesPathPrefix + value)
if _, err := os.Stat(path); os.IsNotExist(err) {
if release.MissingFileHandler == nil && *release.MissingFileHandler == "Error" {
if release.MissingFileHandler == nil || *release.MissingFileHandler == "Error" {
return nil, err
} else {
} else if *release.MissingFileHandler == "Warn" {
st.logger.Warnf("skipping missing secrets file \"%s\"", path)
continue
} else if *release.MissingFileHandler == "Info" {
st.logger.Infof("skipping missing secrets file \"%s\"", path)
continue
} else {
st.logger.Debugf("skipping missing secrets file \"%s\"", path)
continue
}
}

Expand Down

0 comments on commit 5f52f96

Please sign in to comment.