MCPcopy
hub / github.com/wavetermdev/waveterm / GetClientPlatform

Function GetClientPlatform

pkg/wslconn/wsl-util.go:66–84  ·  view source on GitHub ↗

returns (os, arch, error) guaranteed to return a supported platform

(ctx context.Context, shell genconn.ShellClient)

Source from the content-addressed store, hash-verified

64// returns (os, arch, error)
65// guaranteed to return a supported platform
66func GetClientPlatform(ctx context.Context, shell genconn.ShellClient) (string, string, error) {
67 blocklogger.Infof(ctx, "[conndebug] running `uname -sm` to detect client platform\n")
68 stdout, stderr, err := genconn.RunSimpleCommand(ctx, shell, genconn.CommandSpec{
69 Cmd: "uname -sm",
70 })
71 if err != nil {
72 return "", "", fmt.Errorf("error running uname -sm: %w, stderr: %s", err, stderr)
73 }
74 // Parse and normalize output
75 parts := strings.Fields(strings.ToLower(strings.TrimSpace(stdout)))
76 if len(parts) != 2 {
77 return "", "", fmt.Errorf("unexpected output from uname: %s", stdout)
78 }
79 os, arch := normalizeOs(parts[0]), normalizeArch(parts[1])
80 if err := wavebase.ValidateWshSupportedArch(os, arch); err != nil {
81 return "", "", err
82 }
83 return os, arch, nil
84}
85
86func GetClientPlatformFromOsArchStr(ctx context.Context, osArchStr string) (string, string, error) {
87 parts := strings.Fields(strings.TrimSpace(osArchStr))

Callers 1

InstallWshMethod · 0.70

Calls 5

InfofFunction · 0.92
RunSimpleCommandFunction · 0.92
ValidateWshSupportedArchFunction · 0.92
normalizeOsFunction · 0.70
normalizeArchFunction · 0.70

Tested by

no test coverage detected