Skip to content

Commit 94dc41e

Browse files
committed
fix(ipaddress): show full API response in marshaled outputs
1 parent 0ab8546 commit 94dc41e

File tree

3 files changed

+59
-45
lines changed

3 files changed

+59
-45
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2121
- **Breaking**: `storage list` and `storage show` JSON and YAML outputs to return full API response. This changes `servers` field to contain `server` field, which in turn contains the servers. `labels` field will not be outputted if empty.
2222
- **Breaking**: `server list` and `server show` JSON and YAML outputs to return full API response. This changes field `host_id` to `host`. `nics` is replaced with `networking` subfield `interfaces`. `storage` is replaced with `storage_devices`. `labels` contain subfield `label` which in turn contains the labels.
2323
- **Breaking**: `server firewall show` JSON and YAML outputs to return full API response. This removes fields `destination` and `source` fields in favor of `[destination|source]_address_start`, `[destination|source]_address_end`, `[destination|source]_port_start` and `[destination|source]_port_end`
24+
- **Breaking**: In JSON and YAML output of `ip-address list`: display full API response. This changes the top level data-type to object. List of addresses is available under `ip_addresses` key. This changes `partofplan` key to `part_of_plan` and `ptrrecord` key to `ptr_record`.
2425
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group details are available with `kubernetes nodegroup show` command.
2526

27+
## Fixed
28+
- **Breaking**: In JSON and YAML output of `ip-address show`: use same JSON keys as in API documentation. This removes `credits` key that was used in place of `floating`.
29+
2630
## Removed
2731
- **Breaking**: Remove `database connection list` and `database connection cancel` commands in favor of `database session` counterparts
2832

internal/commands/ipaddress/list.go

Lines changed: 42 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,49 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
3636
for i, ipAddress := range ips.IPAddresses {
3737
rows[i] = output.TableRow{ipAddress.Address, ipAddress.Access, ipAddress.Family, ipAddress.PartOfPlan, ipAddress.PTRRecord, ipAddress.ServerUUID, ipAddress.Floating, ipAddress.Zone}
3838
}
39-
return output.Table{
40-
Columns: []output.TableColumn{
41-
{
42-
Header: "Address",
43-
Key: "address",
44-
Colour: ui.DefaultAddressColours,
45-
},
46-
{
47-
Header: "Access",
48-
Key: "access",
49-
},
50-
{
51-
Header: "Family",
52-
Key: "family",
53-
},
54-
{
55-
Header: "Part of Plan",
56-
Key: "partofplan",
57-
Format: format.Boolean,
58-
},
59-
{
60-
Header: "PTR Record",
61-
Key: "ptrrecord",
62-
},
63-
{
64-
Header: "Server",
65-
Key: "server",
66-
Colour: ui.DefaultUUUIDColours,
67-
},
68-
{
69-
Header: "Floating",
70-
Key: "floating",
71-
Format: format.Boolean,
72-
},
73-
{
74-
Header: "Zone",
75-
Key: "zone",
39+
40+
return output.MarshaledWithHumanOutput{
41+
Value: ips,
42+
Output: output.Table{
43+
Columns: []output.TableColumn{
44+
{
45+
Header: "Address",
46+
Key: "address",
47+
Colour: ui.DefaultAddressColours,
48+
},
49+
{
50+
Header: "Access",
51+
Key: "access",
52+
},
53+
{
54+
Header: "Family",
55+
Key: "family",
56+
},
57+
{
58+
Header: "Part of Plan",
59+
Key: "part_of_plan",
60+
Format: format.Boolean,
61+
},
62+
{
63+
Header: "PTR Record",
64+
Key: "ptr_record",
65+
},
66+
{
67+
Header: "Server",
68+
Key: "server",
69+
Colour: ui.DefaultUUUIDColours,
70+
},
71+
{
72+
Header: "Floating",
73+
Key: "floating",
74+
Format: format.Boolean,
75+
},
76+
{
77+
Header: "Zone",
78+
Key: "zone",
79+
},
7680
},
81+
Rows: rows,
7782
},
78-
Rows: rows,
7983
}, nil
8084
}

internal/commands/ipaddress/show.go

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,31 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output
3939
if err != nil {
4040
return nil, err
4141
}
42-
return output.Details{
42+
43+
details := output.Details{
4344
Sections: []output.DetailSection{
4445
{
4546
Rows: []output.DetailRow{
4647
{Title: "Address:", Key: "address", Value: ipAddress.Address, Colour: ui.DefaultAddressColours},
4748
{Title: "Access:", Key: "access", Value: ipAddress.Access},
48-
{Title: "Family:", Key: "access", Value: ipAddress.Family},
49-
{Title: "Part of Plan:", Key: "access", Value: ipAddress.PartOfPlan, Format: format.Boolean},
50-
{Title: "PTR Record:", Key: "access", Value: ipAddress.PTRRecord},
49+
{Title: "Family:", Key: "family", Value: ipAddress.Family},
50+
{Title: "Part of Plan:", Key: "part_of_plan", Value: ipAddress.PartOfPlan, Format: format.Boolean},
51+
{Title: "PTR Record:", Key: "ptr_record", Value: ipAddress.PTRRecord},
5152
{
5253
Title: "Server UUID:",
53-
Key: "access", Value: ipAddress.ServerUUID,
54+
Key: "server", Value: ipAddress.ServerUUID,
5455
Colour: ui.DefaultUUUIDColours,
5556
},
56-
{Title: "MAC:", Key: "credits", Value: ipAddress.MAC},
57-
{Title: "Floating:", Key: "credits", Value: ipAddress.Floating, Format: format.Boolean},
57+
{Title: "MAC:", Key: "mac", Value: ipAddress.MAC},
58+
{Title: "Floating:", Key: "floating", Value: ipAddress.Floating, Format: format.Boolean},
5859
{Title: "Zone:", Key: "zone", Value: ipAddress.Zone},
5960
},
6061
},
6162
},
63+
}
64+
65+
return output.MarshaledWithHumanOutput{
66+
Value: ipAddress,
67+
Output: details,
6268
}, nil
6369
}

0 commit comments

Comments
 (0)