8
8
"log"
9
9
"os"
10
10
"os/exec"
11
+ "runtime"
11
12
"strings"
12
13
13
14
"github.com/yankeguo/ezdeploy"
@@ -18,6 +19,13 @@ import (
18
19
"github.com/yankeguo/rg"
19
20
)
20
21
22
+ func suffixedCommand (name string ) string {
23
+ if runtime .GOOS == "windows" {
24
+ return name + ".exe"
25
+ }
26
+ return name
27
+ }
28
+
21
29
type syncNamespaceOptions struct {
22
30
DB * ezkv.KV
23
31
Kubeconfig string
@@ -113,7 +121,7 @@ func syncResources(ctx context.Context, opts syncResourcesOptions) (err error) {
113
121
args = append (args , "--dry-run=server" )
114
122
}
115
123
116
- cmd := exec .CommandContext (ctx , "kubectl" , args ... )
124
+ cmd := exec .CommandContext (ctx , suffixedCommand ( "kubectl" ) , args ... )
117
125
cmd .Stdin = bytes .NewReader (buf )
118
126
cmd .Stdout = ezlog .NewLogWriter (log .Default (), opts .Title )
119
127
cmd .Stderr = ezlog .NewLogWriter (log .Default (), opts .Title )
@@ -174,7 +182,7 @@ func syncRelease(ctx context.Context, opts syncReleaseOptions) (err error) {
174
182
args = append (args , "--dry-run" )
175
183
}
176
184
177
- cmd := exec .CommandContext (ctx , "helm" , args ... )
185
+ cmd := exec .CommandContext (ctx , suffixedCommand ( "helm" ) , args ... )
178
186
cmd .Stdout = ezlog .NewLogWriter (log .Default (), opts .Title )
179
187
cmd .Stderr = ezlog .NewLogWriter (log .Default (), opts .Title )
180
188
rg .Must0 (cmd .Run ())
0 commit comments