Skip to content

Commit fe4b7de

Browse files
authored
Merge pull request #7019 from scuzhanglei/test-framework-support-customize-kubectl
✨e2e: Support use customize kubectl
2 parents 9545b69 + 723be18 commit fe4b7de

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

test/framework/exec/kubectl.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"bytes"
2121
"context"
2222
"fmt"
23+
"os"
2324
)
2425

2526
// KubectlApply shells out to kubectl apply.
@@ -29,7 +30,7 @@ func KubectlApply(ctx context.Context, kubeconfigPath string, resources []byte,
2930
aargs := append([]string{"apply", "--kubeconfig", kubeconfigPath, "-f", "-"}, args...)
3031
rbytes := bytes.NewReader(resources)
3132
applyCmd := NewCommand(
32-
WithCommand("kubectl"),
33+
WithCommand(kubectlPath()),
3334
WithArgs(aargs...),
3435
WithStdin(rbytes),
3536
)
@@ -46,7 +47,7 @@ func KubectlApply(ctx context.Context, kubeconfigPath string, resources []byte,
4647
func KubectlWait(ctx context.Context, kubeconfigPath string, args ...string) error {
4748
wargs := append([]string{"wait", "--kubeconfig", kubeconfigPath}, args...)
4849
wait := NewCommand(
49-
WithCommand("kubectl"),
50+
WithCommand(kubectlPath()),
5051
WithArgs(wargs...),
5152
)
5253
_, stderr, err := wait.Run(ctx)
@@ -56,3 +57,10 @@ func KubectlWait(ctx context.Context, kubeconfigPath string, args ...string) err
5657
}
5758
return nil
5859
}
60+
61+
func kubectlPath() string {
62+
if kubectlPath, ok := os.LookupEnv("CAPI_KUBECTL_PATH"); ok {
63+
return kubectlPath
64+
}
65+
return "kubectl"
66+
}

0 commit comments

Comments
 (0)