Skip to content

Commit 36724d8

Browse files
feat(vpc): add support for enable-routing (#4107)
Co-authored-by: Rémy Léone <rleone@scaleway.com>
1 parent 11c1c81 commit 36724d8

File tree

4 files changed

+70
-3
lines changed

4 files changed

+70
-3
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
4+
5+
USAGE:
6+
scw vpc route enable-routing <vpc-id ...> [arg=value ...]
7+
8+
ARGS:
9+
vpc-id VPC ID
10+
[region=fr-par] Region to target. If none is passed will use default region from the config (fr-par | nl-ams | pl-waw)
11+
12+
FLAGS:
13+
-h, --help help for enable-routing
14+
15+
GLOBAL FLAGS:
16+
-c, --config string The path to the config file
17+
-D, --debug Enable debug mode
18+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
19+
-p, --profile string The config profile to use

cmd/scw/testdata/test-all-usage-vpc-route-usage.golden

+6-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@
33
Custom routes.
44

55
USAGE:
6-
scw vpc route
6+
scw vpc route <command>
7+
8+
AVAILABLE COMMANDS:
9+
enable-routing Enable routing on a VPC
710

811
FLAGS:
912
-h, --help help for route
@@ -13,3 +16,5 @@ GLOBAL FLAGS:
1316
-D, --debug Enable debug mode
1417
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1518
-p, --profile string The config profile to use
19+
20+
Use "scw vpc route [command] --help" for more information about a command.

docs/commands/vpc.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ This API allows you to manage your Virtual Private Clouds (VPCs) and Private Net
1111
- [Migrate Private Networks from zoned to regional](#migrate-private-networks-from-zoned-to-regional)
1212
- [Update Private Network](#update-private-network)
1313
- [Route management command](#route-management-command)
14+
- [Enable routing on a VPC](#enable-routing-on-a-vpc)
1415
- [Routes management command](#routes-management-command)
1516
- [Return routes with associated next hop data](#return-routes-with-associated-next-hop-data)
1617
- [Subnet management command](#subnet-management-command)
@@ -189,15 +190,26 @@ scw vpc private-network update <private-network-id ...> [arg=value ...]
189190

190191
Custom routes.
191192

192-
Custom routes.
193+
194+
### Enable routing on a VPC
195+
196+
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
193197

194198
**Usage:**
195199

196200
```
197-
scw vpc route
201+
scw vpc route enable-routing <vpc-id ...> [arg=value ...]
198202
```
199203

200204

205+
**Args:**
206+
207+
| Name | | Description |
208+
|------|---|-------------|
209+
| vpc-id | Required | VPC ID |
210+
| region | Default: `fr-par`<br />One of: `fr-par`, `nl-ams`, `pl-waw` | Region to target. If none is passed will use default region from the config |
211+
212+
201213

202214
## Routes management command
203215

internal/namespaces/vpc/v2/vpc_cli.go

+31
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func GetGeneratedCommands() *core.Commands {
3737
vpcPrivateNetworkDelete(),
3838
vpcPrivateNetworkMigrateToRegional(),
3939
vpcPrivateNetworkEnableDHCP(),
40+
vpcRouteEnableRouting(),
4041
vpcRoutesList(),
4142
)
4243
}
@@ -656,6 +657,36 @@ func vpcPrivateNetworkEnableDHCP() *core.Command {
656657
}
657658
}
658659

660+
func vpcRouteEnableRouting() *core.Command {
661+
return &core.Command{
662+
Short: `Enable routing on a VPC`,
663+
Long: `Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.`,
664+
Namespace: "vpc",
665+
Resource: "route",
666+
Verb: "enable-routing",
667+
// Deprecated: false,
668+
ArgsType: reflect.TypeOf(vpc.EnableRoutingRequest{}),
669+
ArgSpecs: core.ArgSpecs{
670+
{
671+
Name: "vpc-id",
672+
Short: `VPC ID`,
673+
Required: true,
674+
Deprecated: false,
675+
Positional: true,
676+
},
677+
core.RegionArgSpec(scw.RegionFrPar, scw.RegionNlAms, scw.RegionPlWaw),
678+
},
679+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
680+
request := args.(*vpc.EnableRoutingRequest)
681+
682+
client := core.ExtractClient(ctx)
683+
api := vpc.NewAPI(client)
684+
return api.EnableRouting(request)
685+
686+
},
687+
}
688+
}
689+
659690
func vpcRoutesList() *core.Command {
660691
return &core.Command{
661692
Short: `Return routes with associated next hop data`,

0 commit comments

Comments
 (0)