From dc131eebcebbe1d508295962bbff6fb61259c06f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4lim=C3=A4ki?= <ville.valimaki@upcloud.com> Date: Mon, 16 Oct 2023 15:23:47 +0300 Subject: [PATCH 1/3] fix(router): show full API response in marshaled outputs after filtering --- CHANGELOG.md | 3 +++ internal/commands/router/list.go | 18 +++++++++++------- internal/commands/router/show.go | 5 ++++- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f58ad254..fa30beacc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `database session cancel` for cancelling an active database session ### Changed +- **Breaking**: `router list` JSON and YAML outputs to return full API response +- **Breaking**: `router show` JSON and YAML outputs to return full API response +- **Breaking**: `server firewall show` JSON and YAML outputs to return full API response - In human readable output of `kubernetes show` command, show node-groups as table. Node-group datails are available with `kubernetes nodegroup show` command. ## Removed diff --git a/internal/commands/router/list.go b/internal/commands/router/list.go index eb3dfc7cd..4e7da7412 100644 --- a/internal/commands/router/list.go +++ b/internal/commands/router/list.go @@ -50,7 +50,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou if s.serviceRouters.Value() { s.normalRouters = config.False } - var filtered []upcloud.Router + filtered := make([]upcloud.Router, 0) if s.allRouters.Value() { filtered = routers.Routers } else { @@ -67,12 +67,16 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou for i, router := range filtered { rows[i] = output.TableRow{router.UUID, router.Name, router.Type} } - return output.Table{ - Columns: []output.TableColumn{ - {Header: "UUID", Key: "uuid", Colour: ui.DefaultUUUIDColours}, - {Header: "Name", Key: "name"}, - {Header: "Type", Key: "type"}, + + return output.MarshaledWithHumanOutput{ + Value: filtered, + Output: output.Table{ + Columns: []output.TableColumn{ + {Header: "UUID", Key: "uuid", Colour: ui.DefaultUUUIDColours}, + {Header: "Name", Key: "name"}, + {Header: "Type", Key: "type"}, + }, + Rows: rows, }, - Rows: rows, }, nil } diff --git a/internal/commands/router/show.go b/internal/commands/router/show.go index 8c1a5e477..29cf0b973 100644 --- a/internal/commands/router/show.go +++ b/internal/commands/router/show.go @@ -86,7 +86,10 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output }, } - return combined, nil + return output.MarshaledWithHumanOutput{ + Value: networks, + Output: combined, + }, nil } func getNetworks(exec commands.Executor, attached upcloud.RouterNetworkSlice) ([]upcloud.Network, error) { From d7cda304febfbaf21eb2a9c16c80e1d68e500a13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4lim=C3=A4ki?= <ville.valimaki@upcloud.com> Date: Mon, 16 Oct 2023 16:35:03 +0300 Subject: [PATCH 2/3] docs(changelog): remove entry as no output changes currently --- CHANGELOG.md | 3 --- 1 file changed, 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa30beacc..1f58ad254 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,9 +17,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `database session cancel` for cancelling an active database session ### Changed -- **Breaking**: `router list` JSON and YAML outputs to return full API response -- **Breaking**: `router show` JSON and YAML outputs to return full API response -- **Breaking**: `server firewall show` JSON and YAML outputs to return full API response - In human readable output of `kubernetes show` command, show node-groups as table. Node-group datails are available with `kubernetes nodegroup show` command. ## Removed From 68468ac83ca1e1a119511030cb1034f0e7b8d819 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ville=20V=C3=A4lim=C3=A4ki?= <ville.valimaki@upcloud.com> Date: Mon, 16 Oct 2023 16:35:21 +0300 Subject: [PATCH 3/3] fix(router): show correct value --- internal/commands/router/show.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/commands/router/show.go b/internal/commands/router/show.go index 29cf0b973..4e896c952 100644 --- a/internal/commands/router/show.go +++ b/internal/commands/router/show.go @@ -87,7 +87,7 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output } return output.MarshaledWithHumanOutput{ - Value: networks, + Value: router, Output: combined, }, nil }