Skip to content

Commit 2ae28a0

Browse files
authored
feat(iam): add iam commands with beta flag (#2378)
1 parent 43a1672 commit 2ae28a0

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

cmd/scw/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/scaleway/scaleway-cli/v2/internal/core"
1212
"github.com/scaleway/scaleway-cli/v2/internal/namespaces"
1313
"github.com/scaleway/scaleway-cli/v2/internal/sentry"
14+
"github.com/scaleway/scaleway-sdk-go/scw"
1415
)
1516

1617
var (
@@ -28,6 +29,7 @@ var (
2829
GoVersion = runtime.Version()
2930
GoOS = runtime.GOOS
3031
GoArch = runtime.GOARCH
32+
BetaMode = os.Getenv(scw.ScwEnableBeta) != ""
3133
)
3234

3335
func cleanup(buildInfo *core.BuildInfo) {
@@ -56,7 +58,7 @@ func main() {
5658

5759
exitCode, _, _ := core.Bootstrap(&core.BootstrapConfig{
5860
Args: os.Args,
59-
Commands: namespaces.GetCommands(),
61+
Commands: namespaces.GetCommands(BetaMode),
6062
BuildInfo: buildInfo,
6163
Stdout: colorable.NewColorableStdout(),
6264
Stderr: colorable.NewColorableStderr(),

internal/namespaces/get_commands.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
flexibleip "github.com/scaleway/scaleway-cli/v2/internal/namespaces/flexibleip/v1alpha1"
1414
function "github.com/scaleway/scaleway-cli/v2/internal/namespaces/function/v1beta1"
1515
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/help"
16+
iam "github.com/scaleway/scaleway-cli/v2/internal/namespaces/iam/v1alpha1"
1617
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/info"
1718
initNamespace "github.com/scaleway/scaleway-cli/v2/internal/namespaces/init"
1819
"github.com/scaleway/scaleway-cli/v2/internal/namespaces/instance/v1"
@@ -32,7 +33,7 @@ import (
3233
// GetCommands returns a list of all commands in the CLI.
3334
// It is used by both scw and scw-qa.
3435
// We can not put it in `core` package as it would result in a import cycle `core` -> `namespaces/autocomplete` -> `core`.
35-
func GetCommands() *core.Commands {
36+
func GetCommands(beta ...bool) *core.Commands {
3637
// Import all commands available in CLI from various packages.
3738
// NB: Merge order impacts scw usage sort.
3839
commands := core.NewCommands()
@@ -61,5 +62,8 @@ func GetCommands() *core.Commands {
6162
commands.Merge(function.GetCommands())
6263
commands.Merge(vpcgw.GetCommands())
6364
commands.Merge(redis.GetCommands())
65+
if len(beta) == 1 && beta[0] {
66+
commands.Merge(iam.GetCommands())
67+
}
6468
return commands
6569
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package iam
2+
3+
import "github.com/scaleway/scaleway-cli/v2/internal/core"
4+
5+
func GetCommands() *core.Commands {
6+
cmds := GetGeneratedCommands()
7+
8+
return cmds
9+
}

0 commit comments

Comments
 (0)