Skip to content

Commit ada0e42

Browse files
committed
fix: invoking kubectl.exe and helm.exe on windows
1 parent c409ef2 commit ada0e42

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Diff for: cmd/ezdeploy/main.go

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
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+
2129
type 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

Comments
 (0)