improve error handling for value rendering (#235)

Fixes #233

Output on values render error:

```
err: failed to render [/Users/sstarcher/xxx/xxx/values.yaml], because of template: stringTemplate:10:18: executing "stringTemplate" at <requiredEnv "HELM_AC...>: error calling requiredEnv: required env var `HELM_ACCOUNT` is not set
```

Also removes panic and sets the output as `apps.Run()` can and will return errors.  Panic makes no sense.

Changelog:

* improve error handling for value rendering

* only output if error exists

* add exit status
This commit is contained in:
Shane Starcher 2018-08-26 20:53:25 -07:00 committed by KUOKA Yusuke
parent fa69ac2cfa
commit 543a653864
2 changed files with 5 additions and 2 deletions

View File

@ -386,7 +386,8 @@ func main() {
err := app.Run(os.Args)
if err != nil {
log.Panicf("[bug] this code path shouldn't be arrived: helmfile is expected to exit from within the `cleanup` func in main.go: %v", err)
logger.Errorf("%v", err)
os.Exit(3)
}
}

View File

@ -703,9 +703,11 @@ func (state *HelmState) namespaceAndValuesFlags(helm helmexec.Interface, basePat
if _, err := os.Stat(path); os.IsNotExist(err) {
return nil, err
}
yamlBuf, err := RenderTemplateFileToBuffer(path)
if err != nil {
return nil, err
return nil, fmt.Errorf("failed to render [%s], because of %v", path, err)
}
valfile, err := ioutil.TempFile("", "values")
if err != nil {