Skip to content

Commit fd94802

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

30 files changed

+826
-646
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: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,16 @@ import (
44
"context"
55
"fmt"
66
"strings"
7-
"time"
87

98
"github.com/spf13/cobra"
10-
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
119
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
1210
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
1311
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
1412
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1513
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1614
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
1715
"github.com/stackitcloud/stackit-cli/internal/pkg/tables"
16+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1817
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1918
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
2019
)
@@ -40,7 +39,7 @@ type inputModel struct {
4039
OrganizationId string
4140
}
4241

43-
func NewCmd(params *params.CmdParams) *cobra.Command {
42+
func NewCmd(params *types.CmdParams) *cobra.Command {
4443
cmd := &cobra.Command{
4544
Use: "create",
4645
Short: "Creates a routing-table",
@@ -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 & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import (
99
"github.com/google/go-cmp/cmp"
1010
"github.com/google/go-cmp/cmp/cmpopts"
1111
"github.com/google/uuid"
12-
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
1312
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
14-
pprint "github.com/stackitcloud/stackit-cli/internal/pkg/print"
13+
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1514
"github.com/stackitcloud/stackit-cli/internal/pkg/testutils"
15+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1616
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1717
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
1818
)
@@ -124,7 +124,7 @@ func TestParseInput(t *testing.T) {
124124
expectedModel: fixtureInputModel(),
125125
},
126126
{
127-
description: "dynamic_routes disabled",
127+
description: "dynamic routes disabled",
128128
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
129129
flagValues[nonDynamicRoutesFlag] = "true"
130130
}),
@@ -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
}),
@@ -308,38 +308,38 @@ func TestOutputResult(t *testing.T) {
308308
}{
309309
{
310310
name: "nil routing-table should return error",
311-
outputFormat: "",
311+
outputFormat: print.PrettyOutputFormat,
312312
routingTable: nil,
313313
wantErr: true,
314314
},
315315
{
316316
name: "empty routing-table",
317-
outputFormat: "",
317+
outputFormat: print.PrettyOutputFormat,
318318
routingTable: &iaas.RoutingTable{},
319319
wantErr: true,
320320
},
321321
{
322-
name: "table output routing-table",
323-
outputFormat: "",
322+
name: "pretty output routing-table",
323+
outputFormat: print.PrettyOutputFormat,
324324
routingTable: &dummyRoutingTable,
325325
wantErr: false,
326326
},
327327
{
328328
name: "json output routing-table",
329-
outputFormat: pprint.JSONOutputFormat,
329+
outputFormat: print.JSONOutputFormat,
330330
routingTable: &dummyRoutingTable,
331331
wantErr: false,
332332
},
333333
{
334334
name: "yaml output routing-table",
335-
outputFormat: pprint.YAMLOutputFormat,
335+
outputFormat: print.YAMLOutputFormat,
336336
routingTable: &dummyRoutingTable,
337337
wantErr: false,
338338
},
339339
}
340340

341-
p := pprint.NewPrinter()
342-
p.Cmd = NewCmd(&params.CmdParams{Printer: p})
341+
p := print.NewPrinter()
342+
p.Cmd = NewCmd(&types.CmdParams{Printer: p})
343343
for _, tt := range tests {
344344
t.Run(tt.name, func(t *testing.T) {
345345
if err := outputResult(p, tt.outputFormat, tt.routingTable); (err != nil) != tt.wantErr {

internal/cmd/routingtable/delete/delete.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import (
55
"fmt"
66

77
"github.com/spf13/cobra"
8-
"github.com/stackitcloud/stackit-cli/internal/cmd/params"
98
"github.com/stackitcloud/stackit-cli/internal/pkg/args"
109
"github.com/stackitcloud/stackit-cli/internal/pkg/examples"
1110
"github.com/stackitcloud/stackit-cli/internal/pkg/flags"
1211
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1312
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1413
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
14+
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1616
)
1717

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 {
@@ -28,7 +28,7 @@ type inputModel struct {
2828
RoutingTableId string
2929
}
3030

31-
func NewCmd(params *params.CmdParams) *cobra.Command {
31+
func NewCmd(params *types.CmdParams) *cobra.Command {
3232
cmd := &cobra.Command{
3333
Use: fmt.Sprintf("delete %s", routingTableIdArg),
3434
Short: "Deletes a routing-table",
@@ -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)