@@ -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,
4647func 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