Skip to content

Commit

Permalink
fix(ipaddress): show full API response in marshaled outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
kangasta committed Oct 16, 2023
1 parent 0ab8546 commit 94dc41e
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 45 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **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.
- **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.
- **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`
- **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`.
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group details are available with `kubernetes nodegroup show` command.

## Fixed
- **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`.

## Removed
- **Breaking**: Remove `database connection list` and `database connection cancel` commands in favor of `database session` counterparts

Expand Down
80 changes: 42 additions & 38 deletions internal/commands/ipaddress/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,45 +36,49 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
for i, ipAddress := range ips.IPAddresses {
rows[i] = output.TableRow{ipAddress.Address, ipAddress.Access, ipAddress.Family, ipAddress.PartOfPlan, ipAddress.PTRRecord, ipAddress.ServerUUID, ipAddress.Floating, ipAddress.Zone}
}
return output.Table{
Columns: []output.TableColumn{
{
Header: "Address",
Key: "address",
Colour: ui.DefaultAddressColours,
},
{
Header: "Access",
Key: "access",
},
{
Header: "Family",
Key: "family",
},
{
Header: "Part of Plan",
Key: "partofplan",
Format: format.Boolean,
},
{
Header: "PTR Record",
Key: "ptrrecord",
},
{
Header: "Server",
Key: "server",
Colour: ui.DefaultUUUIDColours,
},
{
Header: "Floating",
Key: "floating",
Format: format.Boolean,
},
{
Header: "Zone",
Key: "zone",

return output.MarshaledWithHumanOutput{
Value: ips,
Output: output.Table{
Columns: []output.TableColumn{
{
Header: "Address",
Key: "address",
Colour: ui.DefaultAddressColours,
},
{
Header: "Access",
Key: "access",
},
{
Header: "Family",
Key: "family",
},
{
Header: "Part of Plan",
Key: "part_of_plan",
Format: format.Boolean,
},
{
Header: "PTR Record",
Key: "ptr_record",
},
{
Header: "Server",
Key: "server",
Colour: ui.DefaultUUUIDColours,
},
{
Header: "Floating",
Key: "floating",
Format: format.Boolean,
},
{
Header: "Zone",
Key: "zone",
},
},
Rows: rows,
},
Rows: rows,
}, nil
}
20 changes: 13 additions & 7 deletions internal/commands/ipaddress/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,31 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output
if err != nil {
return nil, err
}
return output.Details{

details := output.Details{
Sections: []output.DetailSection{
{
Rows: []output.DetailRow{
{Title: "Address:", Key: "address", Value: ipAddress.Address, Colour: ui.DefaultAddressColours},
{Title: "Access:", Key: "access", Value: ipAddress.Access},
{Title: "Family:", Key: "access", Value: ipAddress.Family},
{Title: "Part of Plan:", Key: "access", Value: ipAddress.PartOfPlan, Format: format.Boolean},
{Title: "PTR Record:", Key: "access", Value: ipAddress.PTRRecord},
{Title: "Family:", Key: "family", Value: ipAddress.Family},
{Title: "Part of Plan:", Key: "part_of_plan", Value: ipAddress.PartOfPlan, Format: format.Boolean},
{Title: "PTR Record:", Key: "ptr_record", Value: ipAddress.PTRRecord},
{
Title: "Server UUID:",
Key: "access", Value: ipAddress.ServerUUID,
Key: "server", Value: ipAddress.ServerUUID,
Colour: ui.DefaultUUUIDColours,
},
{Title: "MAC:", Key: "credits", Value: ipAddress.MAC},
{Title: "Floating:", Key: "credits", Value: ipAddress.Floating, Format: format.Boolean},
{Title: "MAC:", Key: "mac", Value: ipAddress.MAC},
{Title: "Floating:", Key: "floating", Value: ipAddress.Floating, Format: format.Boolean},
{Title: "Zone:", Key: "zone", Value: ipAddress.Zone},
},
},
},
}

return output.MarshaledWithHumanOutput{
Value: ipAddress,
Output: details,
}, nil
}

0 comments on commit 94dc41e

Please sign in to comment.