Skip to content

Commit

Permalink
fix(storage): show full API response in marshaled outputs after filt…
Browse files Browse the repository at this point in the history
…er (#254)
  • Loading branch information
villevsv-upcloud authored Oct 16, 2023
1 parent 29b94cd commit 3eb94a9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
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

0 comments on commit 3eb94a9

Please sign in to comment.