Skip to content

Commit 3eb94a9

Browse files
fix(storage): show full API response in marshaled outputs after filter (#254)
1 parent 29b94cd commit 3eb94a9

3 files changed

Lines changed: 21 additions & 14 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818

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

2324
## Removed

internal/commands/storage/list.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
5959
}
6060

6161
CachedStorages = storageList.Storages
62-
var filtered []upcloud.Storage
62+
filtered := make([]upcloud.Storage, 0)
6363
for _, v := range storageList.Storages {
6464
if s.all.Value() {
6565
filtered = append(filtered, v)
@@ -109,18 +109,21 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
109109
})
110110
}
111111

112-
return output.Table{
113-
Columns: []output.TableColumn{
114-
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
115-
{Key: "title", Header: "Title"},
116-
{Key: "type", Header: "Type"},
117-
{Key: "size", Header: "Size"},
118-
{Key: "state", Header: "State", Format: format.StorageState},
119-
{Key: "tier", Header: "Tier"},
120-
{Key: "zone", Header: "Zone"},
121-
{Key: "access", Header: "Access"},
122-
{Key: "created", Header: "Created"},
112+
return output.MarshaledWithHumanOutput{
113+
Value: filtered,
114+
Output: output.Table{
115+
Columns: []output.TableColumn{
116+
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
117+
{Key: "title", Header: "Title"},
118+
{Key: "type", Header: "Type"},
119+
{Key: "size", Header: "Size"},
120+
{Key: "state", Header: "State", Format: format.StorageState},
121+
{Key: "tier", Header: "Tier"},
122+
{Key: "zone", Header: "Zone"},
123+
{Key: "access", Header: "Access"},
124+
{Key: "created", Header: "Created"},
125+
},
126+
Rows: rows,
123127
},
124-
Rows: rows,
125128
}, nil
126129
}

internal/commands/storage/show.go

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

116-
return combined, nil
116+
return output.MarshaledWithHumanOutput{
117+
Value: storage,
118+
Output: combined,
119+
}, nil
117120
}
118121

119122
func formatShowServers(val interface{}) (text.Colors, string, error) {

0 commit comments

Comments
 (0)