Skip to content

Commit 4732977

Browse files
kvapsclaude
andauthored
fix(template): require --file or --template flag (#112)
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). Signed-off-by: Andrei Kvapil <[email protected]> Co-authored-by: Claude <[email protected]>
1 parent e4f5cf8 commit 4732977

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

‎pkg/commands/template.go‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ var templateCmd = &cobra.Command{
9696
templateFunc := template
9797
if len(templateCmdFlags.configFiles) > 0 {
9898
templateFunc = templateWithFiles
99-
if len(templateCmdFlags.configFiles) == 0 {
100-
return fmt.Errorf("cannot use --in-place without --file")
101-
}
10299
}
103100

104101
if templateCmdFlags.offline {

‎pkg/engine/engine.go‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,10 @@ func Render(ctx context.Context, c *client.Client, opts Options) ([]byte, error)
241241
return nil, err
242242
}
243243

244+
if len(opts.TemplateFiles) == 0 {
245+
return nil, fmt.Errorf("templates are not set for the command: please use `--file` or `--template` flag")
246+
}
247+
244248
configPatches := []string{}
245249
for _, templateFile := range opts.TemplateFiles {
246250
// Use path.Join (not filepath.Join) because helm engine keys always use forward slashes

0 commit comments

Comments
 (0)