Skip to content

Commit bbb6b78

Browse files
committed
review changes 3
1 parent 49d4669 commit bbb6b78

28 files changed

+835
-595
lines changed

docs/stackit_routing-table_create.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ stackit routing-table create [flags]
1919
Create a routing-table with name `rt` and description `some description`
2020
stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --description "some description"
2121
22-
Create a routing-table with name `rt` with system_routes disabled
22+
Create a routing-table with name `rt` with system routes disabled
2323
stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --non-system-routes
2424
25-
Create a routing-table with name `rt` with dynamic_routes disabled
25+
Create a routing-table with name `rt` with dynamic routes disabled
2626
stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --non-dynamic-routes
2727
```
2828

docs/stackit_routing-table_delete.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Deletes a routing-table
77
Deletes a routing-table
88

99
```
10-
stackit routing-table delete ROUTING_TABLE_ARG [flags]
10+
stackit routing-table delete ROUTING_TABLE [flags]
1111
```
1212

1313
### Examples

docs/stackit_routing-table_describe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Describes a routing-table
77
Describes a routing-table
88

99
```
10-
stackit routing-table describe ROUTING_TABLE_ID_ARG [flags]
10+
stackit routing-table describe ROUTING_TABLE_ID [flags]
1111
```
1212

1313
### Examples

docs/stackit_routing-table_route_describe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Describes a route within a routing-table
77
Describes a route within a routing-table
88

99
```
10-
stackit routing-table route describe ROUTE_ID_ARG [flags]
10+
stackit routing-table route describe ROUTE_ID [flags]
1111
```
1212

1313
### Examples

docs/stackit_routing-table_route_update.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Updates a route in a routing-table
77
Updates a route in a routing-table.
88

99
```
10-
stackit routing-table route update ROUTE_ID_ARG [flags]
10+
stackit routing-table route update ROUTE_ID [flags]
1111
```
1212

1313
### Examples

docs/stackit_routing-table_update.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Updates a routing-table
77
Updates a routing-table.
88

99
```
10-
stackit routing-table update ROUTE_TABLE_ID_ARG [flags]
10+
stackit routing-table update ROUTE_TABLE_ID [flags]
1111
```
1212

1313
### Examples
@@ -22,7 +22,7 @@ stackit routing-table update ROUTE_TABLE_ID_ARG [flags]
2222
Updates the description of a routing-table with ID "xxx" in organization with ID "yyy" and network-area with ID "zzz"
2323
$ stackit routing-table update xxx --description foo --organization-id yyy --network-area-id zzz
2424
25-
Disables the dynamic_routes of a routing-table with ID "xxx" in organization with ID "yyy" and network-area with ID "zzz"
25+
Disables the dynamic routes of a routing-table with ID "xxx" in organization with ID "yyy" and network-area with ID "zzz"
2626
$ stackit routing-table update xxx --organization-id yyy --network-area-id zzz --non-dynamic-routes
2727
```
2828

internal/cmd/network/describe/describe.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ func outputResult(p *print.Printer, outputFormat string, network *iaas.Network)
152152
table.AddSeparator()
153153

154154
if network.RoutingTableId != nil {
155-
table.AddRow("ROUTING-TABLE ID", utils.PtrString(network.RoutingTableId))
155+
table.AddRow("ROUTING TABLE ID", utils.PtrString(network.RoutingTableId))
156156
table.AddSeparator()
157157
}
158158

internal/cmd/routingtable/create/create.go

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66
"strings"
7-
"time"
87

98
"github.com/spf13/cobra"
109
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
@@ -56,11 +55,11 @@ func NewCmd(params *params.CmdParams) *cobra.Command {
5655
`stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --description "some description"`,
5756
),
5857
examples.NewExample(
59-
"Create a routing-table with name `rt` with system_routes disabled",
58+
"Create a routing-table with name `rt` with system routes disabled",
6059
`stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --non-system-routes`,
6160
),
6261
examples.NewExample(
63-
"Create a routing-table with name `rt` with dynamic_routes disabled",
62+
"Create a routing-table with name `rt` with dynamic routes disabled",
6463
`stackit routing-table create --organization-id xxx --network-area-id yyy --name "rt" --non-dynamic-routes`,
6564
),
6665
),
@@ -175,28 +174,18 @@ func outputResult(p *print.Printer, outputFormat string, routingTable *iaas.Rout
175174
}
176175
}
177176

178-
createdAt := ""
179-
if routingTable.CreatedAt != nil {
180-
createdAt = routingTable.CreatedAt.Format(time.RFC3339)
181-
}
182-
183-
updatedAt := ""
184-
if routingTable.UpdatedAt != nil {
185-
updatedAt = routingTable.UpdatedAt.Format(time.RFC3339)
186-
}
187-
188177
table := tables.NewTable()
189-
table.SetHeader("ID", "NAME", "DESCRIPTION", "CREATED_AT", "UPDATED_AT", "DEFAULT", "LABELS", "SYSTEM_ROUTES", "DYNAMIC_ROUTES")
178+
table.SetHeader("ID", "NAME", "DESCRIPTION", "DEFAULT", "LABELS", "SYSTEM ROUTES", "DYNAMIC ROUTES", "CREATED AT", "UPDATED AT")
190179
table.AddRow(
191180
utils.PtrString(routingTable.Id),
192181
utils.PtrString(routingTable.Name),
193182
utils.PtrString(routingTable.Description),
194-
createdAt,
195-
updatedAt,
196183
utils.PtrString(routingTable.Default),
197184
strings.Join(labels, "\n"),
198185
utils.PtrString(routingTable.SystemRoutes),
199186
utils.PtrString(routingTable.DynamicRoutes),
187+
utils.ConvertTimePToDateTimeString(routingTable.CreatedAt),
188+
utils.ConvertTimePToDateTimeString(routingTable.UpdatedAt),
200189
)
201190

202191
err := table.Display(p)

internal/cmd/routingtable/create/create_test.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/google/uuid"
1212
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
14-
pprint "github.com/stackitcloud/stackit-cli/internal/pkg/print"
14+
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
1616
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1717
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
@@ -134,7 +134,7 @@ func TestParseInput(t *testing.T) {
134134
}),
135135
},
136136
{
137-
description: "system_routes disabled",
137+
description: "system routes disabled",
138138
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
139139
flagValues[nonSystemRoutesFlag] = "true"
140140
}),
@@ -319,26 +319,32 @@ func TestOutputResult(t *testing.T) {
319319
wantErr: true,
320320
},
321321
{
322-
name: "table output routing-table",
322+
name: "default output routing-table",
323323
outputFormat: "",
324324
routingTable: &dummyRoutingTable,
325325
wantErr: false,
326326
},
327+
{
328+
name: "table output routing-table",
329+
outputFormat: print.PrettyOutputFormat,
330+
routingTable: &dummyRoutingTable,
331+
wantErr: false,
332+
},
327333
{
328334
name: "json output routing-table",
329-
outputFormat: pprint.JSONOutputFormat,
335+
outputFormat: print.JSONOutputFormat,
330336
routingTable: &dummyRoutingTable,
331337
wantErr: false,
332338
},
333339
{
334340
name: "yaml output routing-table",
335-
outputFormat: pprint.YAMLOutputFormat,
341+
outputFormat: print.YAMLOutputFormat,
336342
routingTable: &dummyRoutingTable,
337343
wantErr: false,
338344
},
339345
}
340346

341-
p := pprint.NewPrinter()
347+
p := print.NewPrinter()
342348
p.Cmd = NewCmd(&params.CmdParams{Printer: p})
343349
for _, tt := range tests {
344350
t.Run(tt.name, func(t *testing.T) {

internal/cmd/routingtable/delete/delete.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
const (
1919
networkAreaIdFlag = "network-area-id"
2020
organizationIdFlag = "organization-id"
21-
routingTableIdArg = "ROUTING_TABLE_ARG"
21+
routingTableIdArg = "ROUTING_TABLE"
2222
)
2323

2424
type inputModel struct {
@@ -94,9 +94,6 @@ func configureFlags(cmd *cobra.Command) {
9494
func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inputModel, error) {
9595
globalFlags := globalflags.Parse(p, cmd)
9696

97-
if len(inputArgs) == 0 {
98-
return nil, fmt.Errorf("at least one argument is required")
99-
}
10097
routingTableId := inputArgs[0]
10198

10299
model := inputModel{

0 commit comments

Comments
 (0)