Skip to content

Commit d600de3

Browse files
authored
Fix panic in in dbaas type show when authorized is nil (#524)
This PR fixes unsafe handling of pointers in dbaas type show command.
1 parent ecc0736 commit d600de3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

cmd/dbaas_type_show.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -171,12 +171,12 @@ func (c *dbaasTypeShowCmd) cmdRun(_ *cobra.Command, _ []string) error { //nolint
171171
out := make(dbaasTypePlanListOutput, len(dt.Plans))
172172
for i := range dt.Plans {
173173
out[i] = dbaasTypePlanListItemOutput{
174-
Name: *dt.Plans[i].Name,
175-
Nodes: *dt.Plans[i].Nodes,
176-
NodeCPUs: *dt.Plans[i].NodeCPUs,
177-
NodeMemory: *dt.Plans[i].NodeMemory,
178-
DiskSpace: *dt.Plans[i].DiskSpace,
179-
Authorized: *dt.Plans[i].Authorized,
174+
Name: utils.DefaultString(dt.Plans[i].Name, ""),
175+
Nodes: utils.DefaultInt64(dt.Plans[i].Nodes, 0),
176+
NodeCPUs: utils.DefaultInt64(dt.Plans[i].NodeCPUs, 0),
177+
NodeMemory: utils.DefaultInt64(dt.Plans[i].NodeMemory, 0),
178+
DiskSpace: utils.DefaultInt64(dt.Plans[i].DiskSpace, 0),
179+
Authorized: utils.DefaultBool(dt.Plans[i].Authorized, false),
180180
}
181181
}
182182
return c.outputFunc(&out, nil)

0 commit comments

Comments
 (0)