@@ -20,6 +20,7 @@ import (
20
20
"bytes"
21
21
"context"
22
22
"fmt"
23
+ "os"
23
24
)
24
25
25
26
// KubectlApply shells out to kubectl apply.
@@ -29,7 +30,7 @@ func KubectlApply(ctx context.Context, kubeconfigPath string, resources []byte,
29
30
aargs := append ([]string {"apply" , "--kubeconfig" , kubeconfigPath , "-f" , "-" }, args ... )
30
31
rbytes := bytes .NewReader (resources )
31
32
applyCmd := NewCommand (
32
- WithCommand ("kubectl" ),
33
+ WithCommand (kubectlPath () ),
33
34
WithArgs (aargs ... ),
34
35
WithStdin (rbytes ),
35
36
)
@@ -46,7 +47,7 @@ func KubectlApply(ctx context.Context, kubeconfigPath string, resources []byte,
46
47
func KubectlWait (ctx context.Context , kubeconfigPath string , args ... string ) error {
47
48
wargs := append ([]string {"wait" , "--kubeconfig" , kubeconfigPath }, args ... )
48
49
wait := NewCommand (
49
- WithCommand ("kubectl" ),
50
+ WithCommand (kubectlPath () ),
50
51
WithArgs (wargs ... ),
51
52
)
52
53
_ , stderr , err := wait .Run (ctx )
@@ -56,3 +57,10 @@ func KubectlWait(ctx context.Context, kubeconfigPath string, args ...string) err
56
57
}
57
58
return nil
58
59
}
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