Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(storage): show full API response in marshaled outputs after filter #254

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Changed
- **Breaking**: In JSON and YAML output of `loadbalancer list`: display full API response. This changes `state` field to `operational_state`.
- **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.
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group datails are available with `kubernetes nodegroup show` command.

## Removed
Expand Down
29 changes: 16 additions & 13 deletions internal/commands/storage/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
}

CachedStorages = storageList.Storages
var filtered []upcloud.Storage
filtered := make([]upcloud.Storage, 0)
for _, v := range storageList.Storages {
if s.all.Value() {
filtered = append(filtered, v)
Expand Down Expand Up @@ -109,18 +109,21 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
})
}

return output.Table{
Columns: []output.TableColumn{
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
{Key: "title", Header: "Title"},
{Key: "type", Header: "Type"},
{Key: "size", Header: "Size"},
{Key: "state", Header: "State", Format: format.StorageState},
{Key: "tier", Header: "Tier"},
{Key: "zone", Header: "Zone"},
{Key: "access", Header: "Access"},
{Key: "created", Header: "Created"},
return output.MarshaledWithHumanOutput{
Value: filtered,
Output: output.Table{
Columns: []output.TableColumn{
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
{Key: "title", Header: "Title"},
{Key: "type", Header: "Type"},
{Key: "size", Header: "Size"},
{Key: "state", Header: "State", Format: format.StorageState},
{Key: "tier", Header: "Tier"},
{Key: "zone", Header: "Zone"},
{Key: "access", Header: "Access"},
{Key: "created", Header: "Created"},
},
Rows: rows,
},
Rows: rows,
}, nil
}
5 changes: 4 additions & 1 deletion internal/commands/storage/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,10 @@ func (s *showCommand) Execute(exec commands.Executor, uuid string) (output.Outpu
})
}

return combined, nil
return output.MarshaledWithHumanOutput{
Value: storage,
Output: combined,
}, nil
}

func formatShowServers(val interface{}) (text.Colors, string, error) {
Expand Down
Loading