From da7a42960c474b426752bd71675a4f51b8f5f4ab Mon Sep 17 00:00:00 2001 From: Jeaeun Kim Date: Wed, 27 Aug 2025 20:46:49 +0900 Subject: [PATCH] chore: store err separately for clarity Signed-off-by: Jeaeun Kim --- pkg/cmd/template.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/cmd/template.go b/pkg/cmd/template.go index a51662385..9909b74d9 100644 --- a/pkg/cmd/template.go +++ b/pkg/cmd/template.go @@ -103,6 +103,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } return err } + savedErr := err // We ignore a potential error here because, when the --debug flag was specified, // we always want to print the YAML, even if it is not valid. The error is still returned afterwards. @@ -177,9 +178,9 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { missing = false } if missing { - if err != nil && settings.Debug { + if savedErr != nil && settings.Debug { // assume the manifest itself is too malformed to be rendered - return err + return savedErr } else { return fmt.Errorf("could not find template %s in chart", f) } @@ -193,7 +194,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { } } - return err + return savedErr }, }