From 2417d703ae5ec71c7fbef2270ce30160803310db Mon Sep 17 00:00:00 2001 From: Andrei Kvapil Date: Thu, 19 Mar 2026 12:38:26 +0100 Subject: [PATCH] fix(template): require --file or --template flag Add validation in engine.Render to return a clear error when no template files are specified, instead of silently producing minimal output. Remove dead code branch in template.go (unreachable condition check). Co-Authored-By: Claude Signed-off-by: Andrei Kvapil --- pkg/commands/template.go | 3 --- pkg/engine/engine.go | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/pkg/commands/template.go b/pkg/commands/template.go index e51cbd9..71c5cb5 100644 --- a/pkg/commands/template.go +++ b/pkg/commands/template.go @@ -96,9 +96,6 @@ var templateCmd = &cobra.Command{ templateFunc := template if len(templateCmdFlags.configFiles) > 0 { templateFunc = templateWithFiles - if len(templateCmdFlags.configFiles) == 0 { - return fmt.Errorf("cannot use --in-place without --file") - } } if templateCmdFlags.offline { diff --git a/pkg/engine/engine.go b/pkg/engine/engine.go index 0a8be47..7238e73 100644 --- a/pkg/engine/engine.go +++ b/pkg/engine/engine.go @@ -241,6 +241,10 @@ func Render(ctx context.Context, c *client.Client, opts Options) ([]byte, error) return nil, err } + if len(opts.TemplateFiles) == 0 { + return nil, fmt.Errorf("templates are not set for the command: please use `--file` or `--template` flag") + } + configPatches := []string{} for _, templateFile := range opts.TemplateFiles { // Use path.Join (not filepath.Join) because helm engine keys always use forward slashes