Skip to content

Commit c0bf262

Browse files
committed
STAC-22163: print platform version on connection success
1 parent ea4007d commit c0bf262

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

cmd/context/common.go

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,25 @@ import (
1313
)
1414

1515
func PrintConnectionSuccess(pr printer.Printer, apiUrl string, serverInfo *stackstate_api.ServerInfo) {
16-
pr.Success(
17-
fmt.Sprintf("Connection verified to %s (StackState version: %s)",
18-
apiUrl,
19-
client.VersionToString(serverInfo.Version),
20-
),
21-
)
16+
if serverInfo.PlatformVersion != nil {
17+
pr.Success(
18+
fmt.Sprintf("Connection verified to %s (Platform version: %d.%d.%d)",
19+
apiUrl,
20+
serverInfo.PlatformVersion.Major,
21+
serverInfo.PlatformVersion.Minor,
22+
serverInfo.PlatformVersion.Patch,
23+
),
24+
)
25+
} else {
26+
// Fallback to serverInfo.Version if platformVersion is not present (an updated client could interact with a server not supporting platformVersion yet).
27+
pr.Success(
28+
fmt.Sprintf("Connection verified to %s (StackState version: %s)",
29+
apiUrl,
30+
client.VersionToString(serverInfo.Version),
31+
),
32+
)
33+
}
34+
2235
}
2336

2437
func ValidateContext(cli *di.Deps, cmd *cobra.Command, cfg *config.StsContext) (*stackstate_api.ServerInfo, common.CLIError) {

0 commit comments

Comments
 (0)