Skip to content

Commit 104f8bc

Browse files
fix(server): show full API response in marshaled outputs (#255)
1 parent 1b09bb4 commit 104f8bc

File tree

4 files changed

+36
-24
lines changed

4 files changed

+36
-24
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1919
### Changed
2020
- **Breaking**: In JSON and YAML output of `loadbalancer list`: display full API response. This changes `state` field to `operational_state`.
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.
22-
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group datails are available with `kubernetes nodegroup show` command.
22+
- **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.
23+
- **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+
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group details are available with `kubernetes nodegroup show` command.
2325

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

internal/commands/server/firewall/show.go

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,28 +99,32 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output
9999
},
100100
})
101101
}
102-
return output.Combined{
103-
output.CombinedSection{
104-
Key: "rules",
105-
Title: "Firewall rules",
106-
Contents: output.Table{
107-
Columns: []output.TableColumn{
108-
{Key: "index", Header: "#"},
109-
{Key: "action", Header: "Action", Format: actionFormat},
110-
{Key: "source", Header: "Source", Format: addressFormat},
111-
{Key: "destination", Header: "Destination", Format: addressFormat},
112-
{Key: "direction", Header: "Dir"},
113-
{Key: "protocol", Header: "Proto", Format: protoFormat},
102+
103+
return output.MarshaledWithHumanOutput{
104+
Value: rules,
105+
Output: output.Combined{
106+
output.CombinedSection{
107+
Key: "rules",
108+
Title: "Firewall rules",
109+
Contents: output.Table{
110+
Columns: []output.TableColumn{
111+
{Key: "index", Header: "#"},
112+
{Key: "action", Header: "Action", Format: actionFormat},
113+
{Key: "source", Header: "Source", Format: addressFormat},
114+
{Key: "destination", Header: "Destination", Format: addressFormat},
115+
{Key: "direction", Header: "Dir"},
116+
{Key: "protocol", Header: "Proto", Format: protoFormat},
117+
},
118+
Rows: fwRows,
114119
},
115-
Rows: fwRows,
116120
},
117-
},
118-
output.CombinedSection{
119-
Contents: output.Details{Sections: []output.DetailSection{
120-
{Rows: []output.DetailRow{
121-
{Key: "enabled", Title: "Enabled", Value: server.Firewall == "on", Format: format.Boolean},
121+
output.CombinedSection{
122+
Contents: output.Details{Sections: []output.DetailSection{
123+
{Rows: []output.DetailRow{
124+
{Key: "enabled", Title: "Enabled", Value: server.Firewall == "on", Format: format.Boolean},
125+
}},
122126
}},
123-
}},
127+
},
124128
},
125129
}, nil
126130
}

internal/commands/server/list.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,12 @@ func (ls *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.O
112112
}
113113
}
114114

115-
return output.Table{
116-
Columns: columns,
117-
Rows: rows,
115+
return output.MarshaledWithHumanOutput{
116+
Value: servers,
117+
Output: output.Table{
118+
Columns: columns,
119+
Rows: rows,
120+
},
118121
}, nil
119122
}
120123

internal/commands/server/show.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,10 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu
239239
})
240240
}
241241

242-
return combined, nil
242+
return output.MarshaledWithHumanOutput{
243+
Value: server,
244+
Output: combined,
245+
}, nil
243246
}
244247

245248
func formatShowIPAddresses(val interface{}) (text.Colors, string, error) {

0 commit comments

Comments
 (0)