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

Function GetClientPlatform

pkg/remote/connutil.go:60–78  ·  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

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

Callers 1

InstallWshMethod · 0.92

Calls 5

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

Tested by

no test coverage detected