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(router): show full API response in marshaled outputs after filter #256

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
18 changes: 11 additions & 7 deletions internal/commands/router/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
5 changes: 4 additions & 1 deletion internal/commands/router/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output
},
}

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

func getNetworks(exec commands.Executor, attached upcloud.RouterNetworkSlice) ([]upcloud.Network, error) {
Expand Down