Skip to content

Commit 4bfcb89

Browse files
authored
fix: update cli whoami for versioning (#3392)
update cli whoami for versioning Signed-off-by: Pedro F. Leao <pedroforestileao@gmail.com>
1 parent 35af3ca commit 4bfcb89

1 file changed

Lines changed: 25 additions & 9 deletions

File tree

pkg/cli/whoami.go

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,50 @@ func (w *whoamiCommand) Execute(ctx core.CommandContext) error {
1717
}
1818

1919
organizationLabel := response.GetOrganizationId()
20+
var canvasSandboxModeEnabled *bool
2021
if response.HasOrganizationId() && response.GetOrganizationId() != "" {
2122
orgResponse, _, err := ctx.API.OrganizationAPI.
2223
OrganizationsDescribeOrganization(ctx.Context, response.GetOrganizationId()).
2324
Execute()
2425

25-
if err == nil &&
26-
orgResponse.Organization.Metadata != nil &&
27-
orgResponse.Organization.Metadata.Name != nil &&
28-
*orgResponse.Organization.Metadata.Name != "" {
29-
organizationLabel = *orgResponse.Organization.Metadata.Name
26+
if err == nil && orgResponse != nil && orgResponse.Organization != nil && orgResponse.Organization.Metadata != nil {
27+
metadata := orgResponse.Organization.Metadata
28+
if metadata.Name != nil && *metadata.Name != "" {
29+
organizationLabel = *metadata.Name
30+
}
31+
32+
if enabled, ok := metadata.GetCanvasSandboxModeEnabledOk(); ok {
33+
canvasSandboxModeEnabled = enabled
34+
}
3035
}
3136
}
3237

3338
if ctx.Renderer.IsText() {
3439
return ctx.Renderer.RenderText(func(stdout io.Writer) error {
40+
sandboxModeLabel := "unknown"
41+
if canvasSandboxModeEnabled != nil {
42+
if *canvasSandboxModeEnabled {
43+
sandboxModeLabel = "enabled"
44+
} else {
45+
sandboxModeLabel = "disabled"
46+
}
47+
}
48+
3549
_, _ = fmt.Fprintf(stdout, "ID: %s\n", response.GetId())
3650
_, _ = fmt.Fprintf(stdout, "Email: %s\n", response.GetEmail())
3751
_, _ = fmt.Fprintf(stdout, "Organization ID: %s\n", response.GetOrganizationId())
3852
_, _ = fmt.Fprintf(stdout, "Organization: %s\n", organizationLabel)
53+
_, _ = fmt.Fprintf(stdout, "Canvas Sandbox Mode: %s\n", sandboxModeLabel)
3954
return nil
4055
})
4156
}
4257

4358
return ctx.Renderer.Render(map[string]any{
44-
"id": response.GetId(),
45-
"email": response.GetEmail(),
46-
"organizationId": response.GetOrganizationId(),
47-
"organizationName": organizationLabel,
59+
"id": response.GetId(),
60+
"email": response.GetEmail(),
61+
"organizationId": response.GetOrganizationId(),
62+
"organizationName": organizationLabel,
63+
"canvasSandboxModeEnabled": canvasSandboxModeEnabled,
4864
})
4965
}
5066

0 commit comments

Comments
 (0)