88	"log" 
99	"os" 
1010	"os/exec" 
11+ 	"runtime" 
1112	"strings" 
1213
1314	"github.com/yankeguo/ezdeploy" 
@@ -18,6 +19,13 @@ import (
1819	"github.com/yankeguo/rg" 
1920)
2021
22+ func  suffixedCommand (name  string ) string  {
23+ 	if  runtime .GOOS  ==  "windows"  {
24+ 		return  name  +  ".exe" 
25+ 	}
26+ 	return  name 
27+ }
28+ 
2129type  syncNamespaceOptions  struct  {
2230	DB          * ezkv.KV 
2331	Kubeconfig  string 
@@ -113,7 +121,7 @@ func syncResources(ctx context.Context, opts syncResourcesOptions) (err error) {
113121		args  =  append (args , "--dry-run=server" )
114122	}
115123
116- 	cmd  :=  exec .CommandContext (ctx , "kubectl" , args ... )
124+ 	cmd  :=  exec .CommandContext (ctx , suffixedCommand ( "kubectl" ) , args ... )
117125	cmd .Stdin  =  bytes .NewReader (buf )
118126	cmd .Stdout  =  ezlog .NewLogWriter (log .Default (), opts .Title )
119127	cmd .Stderr  =  ezlog .NewLogWriter (log .Default (), opts .Title )
@@ -174,7 +182,7 @@ func syncRelease(ctx context.Context, opts syncReleaseOptions) (err error) {
174182		args  =  append (args , "--dry-run" )
175183	}
176184
177- 	cmd  :=  exec .CommandContext (ctx , "helm" , args ... )
185+ 	cmd  :=  exec .CommandContext (ctx , suffixedCommand ( "helm" ) , args ... )
178186	cmd .Stdout  =  ezlog .NewLogWriter (log .Default (), opts .Title )
179187	cmd .Stderr  =  ezlog .NewLogWriter (log .Default (), opts .Title )
180188	rg .Must0 (cmd .Run ())
0 commit comments