Skip to content

Commit ec9afc7

Browse files
authored
feat(obs-paas): include cli for list & select plan (#3002)
1 parent 75e2e37 commit ec9afc7

File tree

7 files changed

+146
-6
lines changed

7 files changed

+146
-6
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
List all pricing plans.
4+
5+
USAGE:
6+
scw cockpit plan list [arg=value ...]
7+
8+
ARGS:
9+
[order-by] (name_asc | name_desc)
10+
11+
FLAGS:
12+
-h, --help help for list
13+
14+
GLOBAL FLAGS:
15+
-c, --config string The path to the config file
16+
-D, --debug Enable debug mode
17+
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
18+
-p, --profile string The config profile to use
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
🎲🎲🎲 EXIT CODE: 0 🎲🎲🎲
2+
🟥🟥🟥 STDERR️️ 🟥🟥🟥️
3+
Select the wanted pricing plan.
4+
5+
USAGE:
6+
scw cockpit plan select [arg=value ...]
7+
8+
ARGS:
9+
[project-id] Project ID to use. If none is passed the default project ID will be used
10+
[plan-id]
11+
12+
FLAGS:
13+
-h, --help help for select
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-cockpit-plan-usage.golden

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
Pricing plans management commands.
44

55
USAGE:
6-
scw cockpit plan
6+
scw cockpit plan <command>
7+
8+
AVAILABLE COMMANDS:
9+
list List plans
10+
select Select pricing plan
711

812
FLAGS:
913
-h, --help help for plan
@@ -13,3 +17,5 @@ GLOBAL FLAGS:
1317
-D, --debug Enable debug mode
1418
-o, --output string Output format: json or human, see 'scw help output' for more info (default "human")
1519
-p, --profile string The config profile to use
20+
21+
Use "scw cockpit plan [command] --help" for more information about a command.

docs/commands/cockpit.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Cockpit API.
2323
- [List grafana users](#list-grafana-users)
2424
- [Reset Grafana user password](#reset-grafana-user-password)
2525
- [Pricing plans management commands](#pricing-plans-management-commands)
26+
- [List plans](#list-plans)
27+
- [Select pricing plan](#select-pricing-plan)
2628
- [Token management commands](#token-management-commands)
2729
- [Create a token](#create-a-token)
2830
- [Delete token](#delete-token)
@@ -378,15 +380,45 @@ scw cockpit grafana-user reset-password [arg=value ...]
378380

379381
Pricing plans management commands.
380382

381-
Pricing plans management commands.
383+
384+
### List plans
385+
386+
List all pricing plans.
382387

383388
**Usage:**
384389

385390
```
386-
scw cockpit plan
391+
scw cockpit plan list [arg=value ...]
387392
```
388393

389394

395+
**Args:**
396+
397+
| Name | | Description |
398+
|------|---|-------------|
399+
| order-by | One of: `name_asc`, `name_desc` | |
400+
401+
402+
403+
### Select pricing plan
404+
405+
Select the wanted pricing plan.
406+
407+
**Usage:**
408+
409+
```
410+
scw cockpit plan select [arg=value ...]
411+
```
412+
413+
414+
**Args:**
415+
416+
| Name | | Description |
417+
|------|---|-------------|
418+
| project-id | | Project ID to use. If none is passed the default project ID will be used |
419+
| plan-id | | |
420+
421+
390422

391423
## Token management commands
392424

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ require (
2222
github.com/moby/buildkit v0.11.5
2323
github.com/opencontainers/go-digest v1.0.0
2424
github.com/pkg/errors v0.9.1
25-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230330162401-14ed2c90a334
25+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230404142259-598b1ac41f06
2626
github.com/spf13/cobra v1.6.1
2727
github.com/spf13/pflag v1.0.5
2828
github.com/stretchr/testify v1.8.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
275275
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
276276
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
277277
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
278-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230330162401-14ed2c90a334 h1:inIaZ6yJnpAbkfxzSaOelPFyEfhFoXZ3srp+kEPhG6o=
279-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230330162401-14ed2c90a334/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
278+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230404142259-598b1ac41f06 h1:QvmCsVGrajhRqLaJNd1KlZduhIkQvKYoUaUdv+I2yTM=
279+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.15.0.20230404142259-598b1ac41f06/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
280280
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646/go.mod h1:JA8cRccbGaA1s33RQf7Y1+q9gHmZX1yB/z9WDN1C6fg=
281281
github.com/secure-systems-lab/go-securesystemslib v0.4.0 h1:b23VGrQhTA8cN2CbBw7/FulN9fTtqYUdS5+Oxzt+DUE=
282282
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=

internal/namespaces/cockpit/v1beta1/cockpit_cli.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ func GetGeneratedCommands() *core.Commands {
4545
cockpitGrafanaUserList(),
4646
cockpitGrafanaUserDelete(),
4747
cockpitGrafanaUserResetPassword(),
48+
cockpitPlanList(),
49+
cockpitPlanSelect(),
4850
)
4951
}
5052
func cockpitRoot() *core.Command {
@@ -727,3 +729,66 @@ func cockpitGrafanaUserResetPassword() *core.Command {
727729
},
728730
}
729731
}
732+
733+
func cockpitPlanList() *core.Command {
734+
return &core.Command{
735+
Short: `List plans`,
736+
Long: `List all pricing plans.`,
737+
Namespace: "cockpit",
738+
Resource: "plan",
739+
Verb: "list",
740+
// Deprecated: false,
741+
ArgsType: reflect.TypeOf(cockpit.ListPlansRequest{}),
742+
ArgSpecs: core.ArgSpecs{
743+
{
744+
Name: "order-by",
745+
Required: false,
746+
Deprecated: false,
747+
Positional: false,
748+
EnumValues: []string{"name_asc", "name_desc"},
749+
},
750+
},
751+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
752+
request := args.(*cockpit.ListPlansRequest)
753+
754+
client := core.ExtractClient(ctx)
755+
api := cockpit.NewAPI(client)
756+
opts := []scw.RequestOption{scw.WithAllPages()}
757+
resp, err := api.ListPlans(request, opts...)
758+
if err != nil {
759+
return nil, err
760+
}
761+
return resp.Plans, nil
762+
763+
},
764+
}
765+
}
766+
767+
func cockpitPlanSelect() *core.Command {
768+
return &core.Command{
769+
Short: `Select pricing plan`,
770+
Long: `Select the wanted pricing plan.`,
771+
Namespace: "cockpit",
772+
Resource: "plan",
773+
Verb: "select",
774+
// Deprecated: false,
775+
ArgsType: reflect.TypeOf(cockpit.SelectPlanRequest{}),
776+
ArgSpecs: core.ArgSpecs{
777+
core.ProjectIDArgSpec(),
778+
{
779+
Name: "plan-id",
780+
Required: false,
781+
Deprecated: false,
782+
Positional: false,
783+
},
784+
},
785+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
786+
request := args.(*cockpit.SelectPlanRequest)
787+
788+
client := core.ExtractClient(ctx)
789+
api := cockpit.NewAPI(client)
790+
return api.SelectPlan(request)
791+
792+
},
793+
}
794+
}

0 commit comments

Comments
 (0)