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:
@@ -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 {
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user