Skip to content

Commit 9c1caf0

Browse files
authored
fix: Enable finch support-bundle generate to execute on Windows whe… (#976)
…re the `uname` command does not exist On Windows environments where the `uname` command is not available, executing `finch support-bundle generate` results in the following error: ``` C:\Users\simpl>"..\..\Program Files\Finch\bin\finch.exe" support-bundle generate time="2024-06-11T23:21:16+09:00" level=info msg="Generating support bundle..." time="2024-06-11T23:21:16+09:00" level=fatal msg="exec: \"uname\": executable file not found in %PATH%" ``` This bug has been reported in the following issue: - #897 Therefore, this fix enables the execution of `finch support-bundle generate` even when the `uname` command is not available on Windows. Issue #, if available: #897 *Description of changes:* The details are described in this commit message. *Testing done:* Yes - [x] I've reviewed the guidance in CONTRIBUTING.md #### License Acceptance By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license. Signed-off-by: Hayato Kiwata <[email protected]>
1 parent c8ebf20 commit 9c1caf0

File tree

2 files changed

+4
-27
lines changed

2 files changed

+4
-27
lines changed

pkg/support/support.go

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"github.com/runfinch/finch/pkg/flog"
2525
"github.com/runfinch/finch/pkg/lima/wrapper"
2626
fpath "github.com/runfinch/finch/pkg/path"
27+
"github.com/runfinch/finch/pkg/system"
2728
"github.com/runfinch/finch/pkg/version"
2829
)
2930

@@ -277,11 +278,7 @@ func (bb *bundleBuilder) getPlatformData() (*PlatformData, error) {
277278
platform.Os = os
278279

279280
// populate arch
280-
arch, err := bb.getArch()
281-
if err != nil {
282-
return nil, err
283-
}
284-
platform.Arch = arch
281+
platform.Arch = bb.getArch()
285282

286283
// populate Finch version
287284
platform.Finch = getFinchVersion()
@@ -305,16 +302,8 @@ func (bb *bundleBuilder) getOSVersion() (string, error) {
305302
return os, nil
306303
}
307304

308-
func (bb *bundleBuilder) getArch() (string, error) {
309-
cmd := bb.ecc.Create("uname", "-m")
310-
out, err := cmd.Output()
311-
if err != nil {
312-
return "", err
313-
}
314-
315-
arch := strings.TrimSuffix(string(out), "\n")
316-
317-
return arch, nil
305+
func (bb *bundleBuilder) getArch() string {
306+
return system.NewStdLib().Arch()
318307
}
319308

320309
func getFinchVersion() string {

pkg/support/support_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
7676
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
7777
}
7878
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
79-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
80-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
8179

8280
config.EXPECT().LogFiles().Return([]string{
8381
"log1",
@@ -122,8 +120,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
122120
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
123121
}
124122
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
125-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
126-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
127123

128124
config.EXPECT().LogFiles().Return([]string{
129125
"log1",
@@ -165,8 +161,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
165161
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
166162
}
167163
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
168-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
169-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
170164

171165
config.EXPECT().LogFiles().Return([]string{
172166
"log1",
@@ -207,8 +201,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
207201
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
208202
}
209203
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
210-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
211-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
212204

213205
config.EXPECT().LogFiles().Return([]string{
214206
"log1",
@@ -249,8 +241,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
249241
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
250242
}
251243
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
252-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
253-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
254244

255245
config.EXPECT().LogFiles().Return([]string{
256246
"log1",
@@ -292,8 +282,6 @@ func TestSupportBundleBuilder_GenerateSupportBundle(t *testing.T) {
292282
ecc.EXPECT().Create("sw_vers", "-productVersion").Return(cmd)
293283
}
294284
cmd.EXPECT().Output().Return([]byte("1.2.3\n"), nil)
295-
ecc.EXPECT().Create("uname", "-m").Return(cmd)
296-
cmd.EXPECT().Output().Return([]byte("arch\n"), nil)
297285

298286
config.EXPECT().LogFiles().Return([]string{
299287
"log1",

0 commit comments

Comments
 (0)