mirror of
https://github.com/helm/helm.git
synced 2026-06-24 08:48:06 +00:00
chore: Improve error reporting for helm template --debug with --show-only
Signed-off-by: Jeaeun Kim <me@kyoku.dev>
This commit is contained in:
@@ -186,7 +186,12 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
missing = false
|
||||
}
|
||||
if missing {
|
||||
return fmt.Errorf("could not find template %s in chart", f)
|
||||
if err != nil && settings.Debug {
|
||||
// assume the manifest itself is too malformed to be rendered
|
||||
return err
|
||||
} else {
|
||||
return fmt.Errorf("could not find template %s in chart", f)
|
||||
}
|
||||
}
|
||||
}
|
||||
for _, m := range manifestsToRender {
|
||||
|
||||
@@ -133,6 +133,12 @@ func TestTemplateCmd(t *testing.T) {
|
||||
wantError: true,
|
||||
golden: "output/template-with-invalid-yaml-debug.txt",
|
||||
},
|
||||
{
|
||||
name: "chart with template with invalid template expression (--debug, --show-only)",
|
||||
cmd: fmt.Sprintf("template '%s' --debug --show-only %s", "testdata/testcharts/chart-with-template-with-invalid-template-expr", "templates/alpine-pod.yaml"),
|
||||
wantError: true,
|
||||
golden: "output/template-with-invalid-template-expr-debug-show-only.txt",
|
||||
},
|
||||
{
|
||||
name: "template skip-tests",
|
||||
cmd: fmt.Sprintf(`template '%s' --skip-tests`, chartPath),
|
||||
|
||||
3
pkg/cmd/testdata/output/template-with-invalid-template-expr-debug-show-only.txt
vendored
Normal file
3
pkg/cmd/testdata/output/template-with-invalid-template-expr-debug-show-only.txt
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
Error: chart-with-template-with-invalid-template-expr/templates/alpine-pod.yaml:7:38
|
||||
executing "chart-with-template-with-invalid-template-expr/templates/alpine-pod.yaml" at <b64enc>:
|
||||
invalid value; expected string
|
||||
8
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/Chart.yaml
vendored
Normal file
8
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/Chart.yaml
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
description: Deploy a basic Alpine Linux pod
|
||||
home: https://helm.sh/helm
|
||||
name: chart-with-template-with-invalid-template-expr
|
||||
sources:
|
||||
- https://github.com/helm/helm
|
||||
version: 0.1.0
|
||||
type: application
|
||||
13
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/README.md
vendored
Normal file
13
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/README.md
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
#Alpine: A simple Helm chart
|
||||
|
||||
Run a single pod of Alpine Linux.
|
||||
|
||||
This example was generated using the command `helm create alpine`.
|
||||
|
||||
The `templates/` directory contains a very simple pod resource with a
|
||||
couple of parameters.
|
||||
|
||||
The `values.yaml` file contains the default values for the
|
||||
`alpine-pod.yaml` template.
|
||||
|
||||
You can install this example using `helm install ./alpine`.
|
||||
@@ -0,0 +1,9 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{.Release.Name}}-{{.Values.Name}}"
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Values.nonExistentKey | b64enc }}
|
||||
image: "alpine:3.9"
|
||||
command: ["/bin/sleep","9000"]
|
||||
1
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/values.yaml
vendored
Normal file
1
pkg/cmd/testdata/testcharts/chart-with-template-with-invalid-template-expr/values.yaml
vendored
Normal file
@@ -0,0 +1 @@
|
||||
Name: my-alpine
|
||||
Reference in New Issue
Block a user