Skip to content

Commit 1b09bb4

Browse files
fix(router): show full API response in marshaled outputs after filter (#256)
1 parent 3eb94a9 commit 1b09bb4

2 files changed

Lines changed: 15 additions & 8 deletions

File tree

internal/commands/router/list.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
5050
if s.serviceRouters.Value() {
5151
s.normalRouters = config.False
5252
}
53-
var filtered []upcloud.Router
53+
filtered := make([]upcloud.Router, 0)
5454
if s.allRouters.Value() {
5555
filtered = routers.Routers
5656
} else {
@@ -67,12 +67,16 @@ func (s *listCommand) ExecuteWithoutArguments(exec commands.Executor) (output.Ou
6767
for i, router := range filtered {
6868
rows[i] = output.TableRow{router.UUID, router.Name, router.Type}
6969
}
70-
return output.Table{
71-
Columns: []output.TableColumn{
72-
{Header: "UUID", Key: "uuid", Colour: ui.DefaultUUUIDColours},
73-
{Header: "Name", Key: "name"},
74-
{Header: "Type", Key: "type"},
70+
71+
return output.MarshaledWithHumanOutput{
72+
Value: filtered,
73+
Output: output.Table{
74+
Columns: []output.TableColumn{
75+
{Header: "UUID", Key: "uuid", Colour: ui.DefaultUUUIDColours},
76+
{Header: "Name", Key: "name"},
77+
{Header: "Type", Key: "type"},
78+
},
79+
Rows: rows,
7580
},
76-
Rows: rows,
7781
}, nil
7882
}

internal/commands/router/show.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,10 @@ func (s *showCommand) Execute(exec commands.Executor, arg string) (output.Output
8686
},
8787
}
8888

89-
return combined, nil
89+
return output.MarshaledWithHumanOutput{
90+
Value: router,
91+
Output: combined,
92+
}, nil
9093
}
9194

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

0 commit comments

Comments
 (0)