1
0
mirror of https://github.com/helm/chart-testing.git synced 2026-02-05 09:45:14 +01:00

Ignore stderr when parsing Helm version (#294)

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 <unguiculus@gmail.com>
This commit is contained in:
Reinhard Nägele
2020-11-30 18:58:06 +01:00
committed by GitHub
parent 4625e8832a
commit 71d0e1e82c
2 changed files with 20 additions and 1 deletions

View File

@@ -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 {
@@ -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 {

View File

@@ -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")
}