Skip to content

Commit

Permalink
Ignore stderr when parsing Helm version (helm#294)
Browse files Browse the repository at this point in the history
Helm v3.4.0 logs a warning about URL deprecation which causes semver
parsing to fail. We need to only read stdout and ignore stderr here.

Signed-off-by: Reinhard Nägele <[email protected]>
  • Loading branch information
unguiculus authored Nov 30, 2020
1 parent 4625e88 commit 71d0e1e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions pkg/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ func (p ProcessExecutor) RunProcessAndCaptureOutput(executable string, execArgs
return p.RunProcessInDirAndCaptureOutput("", executable, execArgs)
}

func (p ProcessExecutor) RunProcessAndCaptureStdout(executable string, execArgs ...interface{}) (string, error) {
return p.RunProcessInDirAndCaptureStdout("", executable, execArgs)
}

func (p ProcessExecutor) RunProcessInDirAndCaptureOutput(workingDirectory string, executable string, execArgs ...interface{}) (string, error) {
cmd, err := p.CreateProcess(executable, execArgs...)
if err != nil {
Expand All @@ -55,6 +59,21 @@ func (p ProcessExecutor) RunProcessInDirAndCaptureOutput(workingDirectory string
return strings.TrimSpace(string(bytes)), nil
}

func (p ProcessExecutor) RunProcessInDirAndCaptureStdout(workingDirectory string, executable string, execArgs ...interface{}) (string, error) {
cmd, err := p.CreateProcess(executable, execArgs...)
if err != nil {
return "", err
}

cmd.Dir = workingDirectory
bytes, err := cmd.Output()

if err != nil {
return "", errors.Wrap(err, "Error running process")
}
return strings.TrimSpace(string(bytes)), nil
}

func (p ProcessExecutor) RunProcess(executable string, execArgs ...interface{}) error {
cmd, err := p.CreateProcess(executable, execArgs...)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion pkg/tool/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,5 @@ func (h Helm) DeleteRelease(namespace string, release string) {
}

func (h Helm) Version() (string, error) {
return h.exec.RunProcessAndCaptureOutput("helm", "version", "--short")
return h.exec.RunProcessAndCaptureStdout("helm", "version", "--short")
}

0 comments on commit 71d0e1e

Please sign in to comment.