helmfile/pkg/tmpl
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
..
context.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
context_funcs.go feat: Better exec error reporting (#1159) 2020-03-29 10:49:02 +09:00
context_funcs_test.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
context_tmpl.go feat: Better exec error reporting (#1159) 2020-03-29 10:49:02 +09:00
context_tmpl_test.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
file_renderer.go fix: --state-values-set panic: value of type interface {} is not assignable to type string (#680) 2019-06-12 13:35:04 +09:00
file_renderer_test.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
get_or_nil.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
get_or_nil_test.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00
text_renderer.go chore: tidy up pkgs (#636) 2019-06-01 13:36:05 +09:00