Skip to content

Commit 54cf26a

Browse files
committed
review changes
1 parent ec4c791 commit 54cf26a

File tree

4 files changed

+36
-27
lines changed

4 files changed

+36
-27
lines changed

docs/stackit_network-area_routing-table_route_create.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,13 @@ stackit network-area routing-table route create [flags]
1414

1515
```
1616
Create a route with CIDRv4 destination and IPv4 nexthop
17-
stackit network-area routing-table route create \
18-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
19-
--destination-type cidrv4 --destination-value <ipv4-cidr> \
20-
--nexthop-type ipv4 --nexthop-value <ipv4-address>
17+
$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv4 --destination-value <ipv4-cidr> --nexthop-type ipv4 --nexthop-value <ipv4-address>
2118
2219
Create a route with CIDRv6 destination and IPv6 nexthop
23-
stackit network-area routing-table route create \
24-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
25-
--destination-type cidrv6 --destination-value <ipv6-cidr> \
26-
--nexthop-type ipv6 --nexthop-value <ipv6-address>
20+
$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv6 --destination-value <ipv6-cidr> --nexthop-type ipv6 --nexthop-value <ipv6-address>
2721
2822
Create a route with CIDRv6 destination and Nexthop Internet
29-
stackit network-area routing-table route create \
30-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
31-
--destination-type cidrv6 --destination-value <ipv6-cidr> \
32-
--nexthop-type internet
23+
$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv6 --destination-value <ipv6-cidr> --nexthop-type internet
3324
```
3425

3526
### Options

internal/cmd/network-area/routingtable/route/create/create.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1414
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1515
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
16+
iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1617
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1718
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1819
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
@@ -59,22 +60,13 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5960
Args: args.NoArgs,
6061
Example: examples.Build(
6162
examples.NewExample("Create a route with CIDRv4 destination and IPv4 nexthop",
62-
`stackit network-area routing-table route create \
63-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
64-
--destination-type cidrv4 --destination-value <ipv4-cidr> \
65-
--nexthop-type ipv4 --nexthop-value <ipv4-address>`),
63+
`$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv4 --destination-value <ipv4-cidr> --nexthop-type ipv4 --nexthop-value <ipv4-address>`),
6664

6765
examples.NewExample("Create a route with CIDRv6 destination and IPv6 nexthop",
68-
`stackit network-area routing-table route create \
69-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
70-
--destination-type cidrv6 --destination-value <ipv6-cidr> \
71-
--nexthop-type ipv6 --nexthop-value <ipv6-address>`),
66+
`$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv6 --destination-value <ipv6-cidr> --nexthop-type ipv6 --nexthop-value <ipv6-address>`),
7267

7368
examples.NewExample("Create a route with CIDRv6 destination and Nexthop Internet",
74-
`stackit network-area routing-table route create \
75-
--routing-table-id xxx --organization-id yyy --network-area-id zzz \
76-
--destination-type cidrv6 --destination-value <ipv6-cidr> \
77-
--nexthop-type internet`),
69+
`$ stackit network-area routing-table route create --routing-table-id xxx --organization-id yyy --network-area-id zzz --destination-type cidrv6 --destination-value <ipv6-cidr> --nexthop-type internet`),
7870
),
7971
RunE: func(cmd *cobra.Command, _ []string) error {
8072
ctx := context.Background()
@@ -88,7 +80,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8880
return err
8981
}
9082

91-
prompt := fmt.Sprintf("Are you sure you want to create a route for routing-table with id %q?", model.RoutingTableId)
83+
routingTableLabel, err := iaasUtils.GetRoutingTableOfAreaName(ctx, apiClient, model.OrganizationId, model.NetworkAreaId, model.Region, model.RoutingTableId)
84+
if err != nil {
85+
params.Printer.Debug(print.ErrorLevel, "get routing-table name: %v", err)
86+
routingTableLabel = model.RoutingTableId
87+
} else if routingTableLabel == "" {
88+
routingTableLabel = model.RoutingTableId
89+
}
90+
91+
prompt := fmt.Sprintf("Are you sure you want to create a route for routing-table with id %q?", routingTableLabel)
9292
err = params.Printer.PromptForConfirmation(prompt)
9393
if err != nil {
9494
return err

internal/cmd/network-area/routingtable/route/delete/delete.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1212
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
14+
iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1415
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1516
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1617
)
@@ -55,7 +56,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5556
return err
5657
}
5758

58-
prompt := fmt.Sprintf("Are you sure you want to delete the route %q in routing-table %q for network area id %q?", model.RouteID, model.RoutingTableId, model.NetworkAreaId)
59+
routingTableLabel, err := iaasUtils.GetRoutingTableOfAreaName(ctx, apiClient, model.OrganizationId, model.NetworkAreaId, model.Region, model.RoutingTableId)
60+
if err != nil {
61+
params.Printer.Debug(print.ErrorLevel, "get routing-table name: %v", err)
62+
routingTableLabel = model.RoutingTableId
63+
} else if routingTableLabel == "" {
64+
routingTableLabel = model.RoutingTableId
65+
}
66+
67+
prompt := fmt.Sprintf("Are you sure you want to delete the route %q in routing-table %q for network area id %q?", model.RouteID, routingTableLabel, model.NetworkAreaId)
5968
err = params.Printer.PromptForConfirmation(prompt)
6069
if err != nil {
6170
return err

internal/cmd/network-area/routingtable/route/update/update.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/stackitcloud/stackit-cli/internal/pkg/globalflags"
1313
"github.com/stackitcloud/stackit-cli/internal/pkg/print"
1414
"github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/client"
15+
iaasUtils "github.com/stackitcloud/stackit-cli/internal/pkg/services/iaas/utils"
1516
"github.com/stackitcloud/stackit-cli/internal/pkg/types"
1617
"github.com/stackitcloud/stackit-cli/internal/pkg/utils"
1718
"github.com/stackitcloud/stackit-sdk-go/services/iaas"
@@ -59,7 +60,15 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
5960
return err
6061
}
6162

62-
prompt := fmt.Sprintf("Are you sure you want to update route %q for routing-table with id %q?", model.RouteId, model.RoutingTableId)
63+
routingTableLabel, err := iaasUtils.GetRoutingTableOfAreaName(ctx, apiClient, model.OrganizationId, model.NetworkAreaId, model.Region, model.RoutingTableId)
64+
if err != nil {
65+
params.Printer.Debug(print.ErrorLevel, "get routing-table name: %v", err)
66+
routingTableLabel = model.RoutingTableId
67+
} else if routingTableLabel == "" {
68+
routingTableLabel = model.RoutingTableId
69+
}
70+
71+
prompt := fmt.Sprintf("Are you sure you want to update route %q for routing-table %q?", model.RouteId, routingTableLabel)
6372
err = params.Printer.PromptForConfirmation(prompt)
6473
if err != nil {
6574
return err

0 commit comments

Comments
 (0)