Skip to content

Commit

Permalink
Fix regression bug in helm.RenderTemplate where it leaks stderr (whic…
Browse files Browse the repository at this point in the history
…h contains warning logs) (#828)
  • Loading branch information
yorinasub17 authored Mar 25, 2021
1 parent 13e7990 commit 44493a6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
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

0 comments on commit 44493a6

Please sign in to comment.