chore: store err separately for clarity

Signed-off-by: Jeaeun Kim <me@kyoku.dev>
pull/31185/head
Jeaeun Kim 4 weeks ago committed by kyokuping
parent e2dab43d55
commit da7a42960c

@ -103,6 +103,7 @@ func newTemplateCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
} }
return err return err
} }
savedErr := err
// We ignore a potential error here because, when the --debug flag was specified, // 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. // 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 missing = false
} }
if missing { if missing {
if err != nil && settings.Debug { if savedErr != nil && settings.Debug {
// assume the manifest itself is too malformed to be rendered // assume the manifest itself is too malformed to be rendered
return err return savedErr
} else { } else {
return fmt.Errorf("could not find template %s in chart", f) 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
}, },
} }

Loading…
Cancel
Save