Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions pkg/commands/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions pkg/engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Comment on lines +244 to +246
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better efficiency, this check should be at the beginning of the Render function. Placing it here means that chart loading and template rendering (loader.LoadDir, loadValues, eng.Render) are performed even when they are not needed, only to fail afterwards. Moving this check to the top of the function would allow it to fail-fast and avoid these unnecessary operations.


configPatches := []string{}
for _, templateFile := range opts.TemplateFiles {
// Use path.Join (not filepath.Join) because helm engine keys always use forward slashes
Expand Down
Loading