Skip to content

Commit c0b1403

Browse files
authored
feat(vpcgw): improve gateway-type list visualization (#2963)
1 parent 9204148 commit c0b1403

File tree

5 files changed

+93
-0
lines changed

5 files changed

+93
-0
lines changed

internal/namespaces/vpcgw/v1/custom.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,7 @@ func GetCommands() *core.Commands {
1212
human.RegisterMarshalerFunc(vpcgw.GatewayNetworkStatus(""), human.EnumMarshalFunc(gatewayNetworkStatusMarshalSpecs))
1313
human.RegisterMarshalerFunc(vpcgw.GatewayStatus(""), human.EnumMarshalFunc(gatewayStatusMarshalSpecs))
1414

15+
cmds.MustFind("vpc-gw", "gateway-type", "list").Override(vpcgwGatewayTypeListBuilder)
16+
1517
return cmds
1618
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package vpcgw
2+
3+
import (
4+
"context"
5+
6+
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
"github.com/scaleway/scaleway-sdk-go/api/vpcgw/v1"
8+
)
9+
10+
func vpcgwGatewayTypeListBuilder(c *core.Command) *core.Command {
11+
c.AddInterceptors(func(ctx context.Context, argsI interface{}, runner core.CommandRunner) (interface{}, error) {
12+
res, err := runner(ctx, argsI)
13+
if err != nil {
14+
return nil, err
15+
}
16+
17+
typesResponse := res.(*vpcgw.ListGatewayTypesResponse)
18+
return typesResponse.Types, nil
19+
})
20+
21+
return c
22+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package vpcgw
2+
3+
import (
4+
"testing"
5+
6+
"github.com/scaleway/scaleway-cli/v2/internal/core"
7+
)
8+
9+
func Test_ListGatewayType(t *testing.T) {
10+
t.Run("Simple", core.Test(&core.TestConfig{
11+
Commands: GetCommands(),
12+
Cmd: "scw vpc-gw gateway-type list",
13+
Check: core.TestCheckGolden(),
14+
}))
15+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
version: 1
3+
interactions:
4+
- request:
5+
body: ""
6+
form: {}
7+
headers:
8+
User-Agent:
9+
- scaleway-sdk-go/v1.0.0-beta.7+dev (go1.19.5; darwin; amd64) cli-e2e-test
10+
url: https://api.scaleway.com/vpc-gw/v1/zones/fr-par-1/gateway-types
11+
method: GET
12+
response:
13+
body: '{"types":[{"name":"VPC-GW-S", "bandwidth":100000000, "zone":"fr-par-1"},
14+
{"name":"VPC-GW-M", "bandwidth":1000000000, "zone":"fr-par-1"}]}'
15+
headers:
16+
Content-Length:
17+
- "137"
18+
Content-Security-Policy:
19+
- default-src 'none'; frame-ancestors 'none'
20+
Content-Type:
21+
- application/json
22+
Date:
23+
- Tue, 28 Mar 2023 13:19:36 GMT
24+
Server:
25+
- Scaleway API-Gateway
26+
Strict-Transport-Security:
27+
- max-age=63072000
28+
X-Content-Type-Options:
29+
- nosniff
30+
X-Frame-Options:
31+
- DENY
32+
X-Request-Id:
33+
- 623afde2-5a9d-4c65-953d-0331be842ae5
34+
status: 200 OK
35+
code: 200
36+
duration: ""
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟩🟩🟩 STDOUT️ 🟩🟩🟩️
3+
NAME BANDWIDTH ZONE
4+
VPC-GW-S 100000000 fr-par-1
5+
VPC-GW-M 1000000000 fr-par-1
6+
🟩🟩🟩 JSON STDOUT 🟩🟩🟩
7+
[
8+
{
9+
"name": "VPC-GW-S",
10+
"bandwidth": 100000000,
11+
"zone": "fr-par-1"
12+
},
13+
{
14+
"name": "VPC-GW-M",
15+
"bandwidth": 1000000000,
16+
"zone": "fr-par-1"
17+
}
18+
]

0 commit comments

Comments
 (0)