Skip to content

Commit b357384

Browse files
Merge branch 'main' into fix/server-output
2 parents 229f48b + 3eb94a9 commit b357384

File tree

6 files changed

+49
-29
lines changed

6 files changed

+49
-29
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- Add `database session cancel` for cancelling an active database session
1818

1919
### Changed
20+
- **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.
2022
- **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.
2123
- **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`
2224
- In human readable output of `kubernetes show` command, show node-groups as table. Node-group details are available with `kubernetes nodegroup show` command.

internal/commands/account/show.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ func (s *showCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
2626
if err != nil {
2727
return nil, err
2828
}
29-
return output.Details{
29+
30+
details, err := output.Details{
3031
Sections: []output.DetailSection{
3132
{
3233
Rows: []output.DetailRow{
@@ -80,6 +81,11 @@ func (s *showCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
8081
},
8182
},
8283
}, nil
84+
85+
return output.MarshaledWithHumanOutput{
86+
Value: account,
87+
Output: details,
88+
}, err
8389
}
8490

8591
func formatCredits(credits float64) string {

internal/commands/loadbalancer/list.go

+11-8
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,17 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
3838
})
3939
}
4040

41-
return output.Table{
42-
Columns: []output.TableColumn{
43-
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
44-
{Key: "name", Header: "Name"},
45-
{Key: "plan", Header: "Plan"},
46-
{Key: "zone", Header: "Zone"},
47-
{Key: "state", Header: "State", Format: format.LoadBalancerState},
41+
return output.MarshaledWithHumanOutput{
42+
Value: loadbalancers,
43+
Output: output.Table{
44+
Columns: []output.TableColumn{
45+
{Key: "uuid", Header: "UUID", Colour: ui.DefaultUUUIDColours},
46+
{Key: "name", Header: "Name"},
47+
{Key: "plan", Header: "Plan"},
48+
{Key: "zone", Header: "Zone"},
49+
{Key: "operational_state", Header: "State", Format: format.LoadBalancerState},
50+
},
51+
Rows: rows,
4852
},
49-
Rows: rows,
5053
}, nil
5154
}

internal/commands/storage/list.go

+16-13
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

+4-1
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) {

internal/commands/zone/list.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
3434
})
3535
}
3636

37-
return output.Table{
38-
Columns: []output.TableColumn{
39-
{Key: "id", Header: "ID"},
40-
{Key: "description", Header: "Description"},
41-
{Key: "public", Header: "Public", Format: format.Boolean},
37+
return output.MarshaledWithHumanOutput{
38+
Value: zones,
39+
Output: output.Table{
40+
Columns: []output.TableColumn{
41+
{Key: "id", Header: "ID"},
42+
{Key: "description", Header: "Description"},
43+
{Key: "public", Header: "Public", Format: format.Boolean},
44+
},
45+
Rows: rows,
4246
},
43-
Rows: rows,
4447
}, nil
4548
}

0 commit comments

Comments
 (0)