Skip to content

Commit 1c3ebb3

Browse files
authored
feat(cockpit): enable and document activate and deactivate methods (#2824)
1 parent ea9efdc commit 1c3ebb3

File tree

3 files changed

+51
-3
lines changed

3 files changed

+51
-3
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/kubernetes-client/go-base v0.0.0-20190205182333-3d0e39759d98
1919
github.com/mattn/go-colorable v0.1.13
2020
github.com/mattn/go-isatty v0.0.17
21-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230228105412-a7fe9ca961db
21+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230302103330-26bd265ecc73
2222
github.com/spf13/cobra v1.6.1
2323
github.com/spf13/pflag v1.0.5
2424
github.com/stretchr/testify v1.8.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ github.com/pkg/term v1.1.0/go.mod h1:E25nymQcrSllhX42Ok8MRm1+hyBdHY0dCeiKZ9jpNGw
7070
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
7171
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
7272
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
73-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230228105412-a7fe9ca961db h1:vZY25aKHeibgVtTf+ucgzbCSs6ra0UKOfbdLNXBKtjA=
74-
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230228105412-a7fe9ca961db/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
73+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230302103330-26bd265ecc73 h1:L+ZRqJKnVPjOMuhRd7mN96K2xbVLYKnvtzQCXanXnMU=
74+
github.com/scaleway/scaleway-sdk-go v1.0.0-beta.13.0.20230302103330-26bd265ecc73/go.mod h1:fCa7OJZ/9DRTnOKmxvT6pn+LPWUptQAmHF/SBJUGEcg=
7575
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
7676
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
7777
github.com/spf13/cobra v1.6.1 h1:o94oiPyS4KD1mPy2fmcYYHHfCxLqYjJOhGsCHFZtEzA=

internal/namespaces/cockpit/v1beta1/cockpit_cli.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ func GetGeneratedCommands() *core.Commands {
2323
cockpitCockpit(),
2424
cockpitToken(),
2525
cockpitGrafanaUser(),
26+
cockpitCockpitActivate(),
2627
cockpitCockpitGet(),
28+
cockpitCockpitDeactivate(),
2729
cockpitCockpitResetGrafana(),
2830
cockpitTokenCreate(),
2931
cockpitTokenList(),
@@ -70,6 +72,29 @@ func cockpitGrafanaUser() *core.Command {
7072
}
7173
}
7274

75+
func cockpitCockpitActivate() *core.Command {
76+
return &core.Command{
77+
Short: `Activate a cockpit`,
78+
Long: `Activate a cockpit associated with the given project ID.`,
79+
Namespace: "cockpit",
80+
Resource: "cockpit",
81+
Verb: "activate",
82+
// Deprecated: false,
83+
ArgsType: reflect.TypeOf(cockpit.ActivateCockpitRequest{}),
84+
ArgSpecs: core.ArgSpecs{
85+
core.ProjectIDArgSpec(),
86+
},
87+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
88+
request := args.(*cockpit.ActivateCockpitRequest)
89+
90+
client := core.ExtractClient(ctx)
91+
api := cockpit.NewAPI(client)
92+
return api.ActivateCockpit(request)
93+
94+
},
95+
}
96+
}
97+
7398
func cockpitCockpitGet() *core.Command {
7499
return &core.Command{
75100
Short: `Get cockpit`,
@@ -93,6 +118,29 @@ func cockpitCockpitGet() *core.Command {
93118
}
94119
}
95120

121+
func cockpitCockpitDeactivate() *core.Command {
122+
return &core.Command{
123+
Short: `Deactivate a cockpit`,
124+
Long: `Deactivate a cockpit associated with the given project ID.`,
125+
Namespace: "cockpit",
126+
Resource: "cockpit",
127+
Verb: "deactivate",
128+
// Deprecated: false,
129+
ArgsType: reflect.TypeOf(cockpit.DeactivateCockpitRequest{}),
130+
ArgSpecs: core.ArgSpecs{
131+
core.ProjectIDArgSpec(),
132+
},
133+
Run: func(ctx context.Context, args interface{}) (i interface{}, e error) {
134+
request := args.(*cockpit.DeactivateCockpitRequest)
135+
136+
client := core.ExtractClient(ctx)
137+
api := cockpit.NewAPI(client)
138+
return api.DeactivateCockpit(request)
139+
140+
},
141+
}
142+
}
143+
96144
func cockpitCockpitResetGrafana() *core.Command {
97145
return &core.Command{
98146
Short: `Reset Grafana`,

0 commit comments

Comments
 (0)