Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix regression bug in helm.RenderTemplate where it leaks stderr #828

Merged
merged 1 commit into from
Mar 25, 2021
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
15 changes: 13 additions & 2 deletions modules/helm/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,19 @@ func getValuesArgsE(t testing.TestingT, options *Options, args ...string) ([]str
return args, nil
}

// RunHelmCommandAndGetOutputE runs helm with the given arguments and options and returns stdout/stderr.
// RunHelmCommandAndGetOutputE runs helm with the given arguments and options and returns combined, interleaved stdout/stderr.
func RunHelmCommandAndGetOutputE(t testing.TestingT, options *Options, cmd string, additionalArgs ...string) (string, error) {
helmCmd := prepareHelmCommand(t, options, cmd, additionalArgs...)
return shell.RunCommandAndGetOutputE(t, helmCmd)
}

// RunHelmCommandAndGetStdOutE runs helm with the given arguments and options and returns stdout.
func RunHelmCommandAndGetStdOutE(t testing.TestingT, options *Options, cmd string, additionalArgs ...string) (string, error) {
helmCmd := prepareHelmCommand(t, options, cmd, additionalArgs...)
return shell.RunCommandAndGetStdOutE(t, helmCmd)
}

func prepareHelmCommand(t testing.TestingT, options *Options, cmd string, additionalArgs ...string) shell.Command {
args := []string{cmd}
args = getCommonArgs(options, args...)
args = append(args, additionalArgs...)
Expand All @@ -63,5 +74,5 @@ func RunHelmCommandAndGetOutputE(t testing.TestingT, options *Options, cmd strin
Env: options.EnvVars,
Logger: options.Logger,
}
return shell.RunCommandAndGetOutputE(t, helmCmd)
return helmCmd
}
2 changes: 1 addition & 1 deletion modules/helm/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func RenderTemplateE(t testing.TestingT, options *Options, chartDir string, rele
args = append(args, releaseName, chartDir)

// Finally, call out to helm template command
return RunHelmCommandAndGetOutputE(t, options, "template", args...)
return RunHelmCommandAndGetStdOutE(t, options, "template", args...)
}

// UnmarshalK8SYaml is the same as UnmarshalK8SYamlE, but will fail the test if there is an error.
Expand Down