Skip to content

Commit 574958b

Browse files
authored
add toggle-apikey flag (#235)
1 parent 026ef1c commit 574958b

3 files changed

Lines changed: 16 additions & 1 deletion

File tree

app/app.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ func NewApp(params AppParams) (*cli.App, error) {
2828
EnableDebugLogsFlag,
2929
},
3030
}
31-
app.Commands = params.Commands
31+
for _, c := range params.Commands {
32+
if !IsFeatureEnabled(APIKeyFeatureFlag) && c.Name == "apikey" {
33+
continue
34+
}
35+
app.Commands = append(app.Commands, c)
36+
}
3237
return app, nil
3338
}

app/feature.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313

1414
var (
1515
ExportFeatureFlag = "enable-export"
16+
APIKeyFeatureFlag = "enable-apikey"
1617
featureflagFileName = "feature.json"
1718
)
1819

@@ -108,6 +109,14 @@ func NewFeatureCommand() (CommandOut, error) {
108109
return toggleFeature(ExportFeatureFlag)
109110
},
110111
},
112+
{
113+
Name: "toggle-apikey",
114+
Aliases: []string{"tak"},
115+
Usage: "switch api keys on/off",
116+
Action: func(c *cli.Context) error {
117+
return toggleFeature(APIKeyFeatureFlag)
118+
},
119+
},
111120
{
112121
Name: "get",
113122
Aliases: []string{"g"},

cmd/tcld/fx.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ func fxOptions() fx.Option {
2222
app.NewLoginCommand,
2323
app.NewLogoutCommand,
2424
app.NewCertificatesCommand,
25+
app.NewAPIKeyCommand,
2526
app.NewFeatureCommand,
2627
func() app.GetNamespaceClientFn {
2728
return app.GetNamespaceClient

0 commit comments

Comments
 (0)