helmfile/pkg
KUOKA Yusuke f676c61425
feat: Better exec error reporting (#1159)
Enhances Helmfile to print more helpful message on error while calling `exec` template function.

Helmfile has been printing error messages like the below:

```
in ./helmfile.yaml: error during helmfile.yaml.part.0 parsing: template: stringTemplate:5:8: executing "stringTemplate" at <exec "./exectest.sha" (list)>: error calling exec: exit status 1
```

Adding captured stdout and stderr, with some indentation to make it readable, it now produces the following message on missing executable:

```
$ make build && ./helmfile build
go build
in ./helmfile.yaml: error during helmfile.yaml.part.0 parsing: template: stringTemplate:5:8: executing "stringTemplate" at <exec "./exectest.sha" (list)>: error calling exec: fork/exec ./exectest.sha: no such file or directory

COMMAND:
  ./exectest.sha

ERROR:
  fork/exec ./exectest.sha: no such file or directory
```

On non-zero exit status without output:

```
$ make build && ./helmfile build
go build
in ./helmfile.yaml: error during helmfile.yaml.part.0 parsing: template: stringTemplate:5:8: executing "stringTemplate" at <exec "./exectest.sh" (list)>: error calling exec: exit status 1

COMMAND:
  ./exectest.sh

ERROR:
  exit status 1
```

On non-zero exit status with output:

```
$ make build && ./helmfile build
go build
in ./helmfile.yaml: error during helmfile.yaml.part.0 parsing: template: stringTemplate:5:8: executing "stringTemplate" at <exec "./exectest.sh" (list)>: error calling exec: exit status 2

COMMAND:
  ./exectest.sh

ERROR:
  exit status 2

COMBINED OUTPUT:
  out1
  err1
```

Resolves #1158
2020-03-29 10:49:02 +09:00
..
app feat: add helmfile template --validate (#1135) 2020-03-05 08:07:02 +09:00
argparser fix: helmDefaults.kubeContext ignored in `helm diff` of `helmfile apply` (#682) 2019-06-12 16:49:19 +09:00
environment feat: state values (#647) 2019-06-04 16:34:02 +09:00
event feat: Enhance postsync event to include `.Error` (#882) 2019-10-17 08:27:12 +09:00
exectest Add option to suppress diff on apply (#1092) 2020-02-05 21:29:55 +09:00
helmexec Add validation for empty repository names (#1128) 2020-02-28 19:42:15 +09:00
maputil Add indexed key support to --state-values-set (#1042) 2019-12-17 07:31:42 +09:00
remote Fix recursion for helmfiles pulled from git (#854) 2019-09-14 05:49:59 +02:00
state feat: add helmfile template --validate (#1135) 2020-03-05 08:07:02 +09:00
testhelper fix: Fix `needs` to work for upgrades and when selectors are provided (#922) 2019-11-02 14:04:16 +09:00
tmpl feat: Better exec error reporting (#1159) 2020-03-29 10:49:02 +09:00