Fix stomping os env in kubectl e2e tests

This commit is contained in:
Jordan Liggitt
2023-04-19 01:32:20 +02:00
parent d97ea0f705
commit 0c54d9af6f
2 changed files with 11 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ import (
"io"
"net"
"net/url"
"os"
"os/exec"
"strings"
"syscall"
@@ -48,9 +49,12 @@ func NewKubectlCommand(namespace string, args ...string) *KubectlBuilder {
return b
}
// WithEnv sets the given environment and returns itself.
func (b *KubectlBuilder) WithEnv(env []string) *KubectlBuilder {
b.cmd.Env = env
// WithEnv appends the given environment and returns itself.
func (b *KubectlBuilder) AppendEnv(env []string) *KubectlBuilder {
if b.cmd.Env == nil {
b.cmd.Env = os.Environ()
}
b.cmd.Env = append(b.cmd.Env, env...)
return b
}