returns (os, arch, error) guaranteed to return a supported platform
(ctx context.Context, shell genconn.ShellClient)
| 58 | // returns (os, arch, error) |
| 59 | // guaranteed to return a supported platform |
| 60 | func 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 | |
| 80 | func GetClientPlatformFromOsArchStr(ctx context.Context, osArchStr string) (string, string, error) { |
| 81 | parts := strings.Fields(strings.TrimSpace(osArchStr)) |
no test coverage detected