diff --git a/internal/cmd/cloud-signup/command.go b/internal/cmd/cloud-signup/command.go index 2eaa990059..713560ee0d 100644 --- a/internal/cmd/cloud-signup/command.go +++ b/internal/cmd/cloud-signup/command.go @@ -19,7 +19,7 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" "github.com/confluentinc/cli/internal/pkg/errors" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" + "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/form" "github.com/confluentinc/cli/internal/pkg/log" "github.com/confluentinc/cli/internal/pkg/utils" @@ -225,7 +225,7 @@ func (c *command) printFreeTrialAnnouncement(cmd *cobra.Command, client *ccloud. if c.isTest { freeTrialPromoCode = testserver.PromoTestCode } else { - freeTrialPromoCode = launchdarkly.Manager.StringVariation("billing.service.signup_promo.promo_code", c.Config.Context(), ldClient, false, "") + freeTrialPromoCode = featureflags.Manager.StringVariation("billing.service.signup_promo.promo_code", c.Config.Context(), ldClient, false, "") } // try to find free trial promo code diff --git a/internal/cmd/command.go b/internal/cmd/command.go index e228269618..289b979104 100644 --- a/internal/cmd/command.go +++ b/internal/cmd/command.go @@ -108,7 +108,6 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { cmd.AddCommand(local.New(prerunner)) cmd.AddCommand(login.New(cfg, prerunner, ccloudClientFactory, mdsClientManager, netrcHandler, loginCredentialsManager, loginOrganizationManager, authTokenHandler)) cmd.AddCommand(logout.New(cfg, prerunner, netrcHandler)) - cmd.AddCommand(pipeline.New(cfg, prerunner)) cmd.AddCommand(plugin.New(cfg, prerunner)) cmd.AddCommand(price.New(prerunner)) cmd.AddCommand(prompt.New(cfg)) @@ -116,10 +115,18 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { cmd.AddCommand(schemaregistry.New(cfg, prerunner, nil)) cmd.AddCommand(secret.New(prerunner, flagResolver, secrets.NewPasswordProtectionPlugin())) cmd.AddCommand(shell.New(cmd, func() *cobra.Command { return NewConfluentCommand(cfg) })) - cmd.AddCommand(streamshare.New(cfg, prerunner)) cmd.AddCommand(update.New(prerunner, cfg.Version, updateClient)) cmd.AddCommand(version.New(prerunner, cfg.Version)) + dc := dynamicconfig.New(cfg, nil, nil) + _ = dc.ParseFlagsIntoConfig(cmd) + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.cdx", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + cmd.AddCommand(streamshare.New(cfg, prerunner)) + } + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.stream_designer", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + cmd.AddCommand(pipeline.New(cfg, prerunner)) + } + changeDefaults(cmd, cfg) deprecateCommandsAndFlags(cmd, cfg) return cmd diff --git a/internal/cmd/iam/command.go b/internal/cmd/iam/command.go index 70c91d50d2..29210a86b4 100644 --- a/internal/cmd/iam/command.go +++ b/internal/cmd/iam/command.go @@ -5,6 +5,8 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" + dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" + "github.com/confluentinc/cli/internal/pkg/featureflags" ) type command struct { @@ -34,9 +36,13 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { prerunner: prerunner, } + dc := dynamicconfig.New(cfg, nil, nil) + _ = dc.ParseFlagsIntoConfig(cmd) + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + c.AddCommand(newPoolCommand(cfg, c.prerunner)) + c.AddCommand(newProviderCommand(cfg, c.prerunner)) + } c.AddCommand(newACLCommand(c.prerunner)) - c.AddCommand(newPoolCommand(cfg, c.prerunner)) - c.AddCommand(newProviderCommand(cfg, c.prerunner)) c.AddCommand(newRBACCommand(cfg, c.prerunner)) c.AddCommand(newServiceAccountCommand(c.prerunner)) c.AddCommand(newUserCommand(c.prerunner)) diff --git a/internal/cmd/iam/command_pool.go b/internal/cmd/iam/command_pool.go index 2fa7fcfd36..0da7b51346 100644 --- a/internal/cmd/iam/command_pool.go +++ b/internal/cmd/iam/command_pool.go @@ -5,8 +5,6 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" - dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" ) type identityPoolCommand struct { @@ -30,10 +28,6 @@ func newPoolCommand(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { c := &identityPoolCommand{pcmd.NewAuthenticatedCLICommand(cmd, prerunner)} - dc := dynamicconfig.New(cfg, nil, nil) - _ = dc.ParseFlagsIntoConfig(cmd) - c.Hidden = !(cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false)) - cmd.AddCommand(c.newCreateCommand()) cmd.AddCommand(c.newDeleteCommand()) cmd.AddCommand(c.newDescribeCommand()) diff --git a/internal/cmd/iam/command_provider.go b/internal/cmd/iam/command_provider.go index 236edd6973..98c2f90ba2 100644 --- a/internal/cmd/iam/command_provider.go +++ b/internal/cmd/iam/command_provider.go @@ -5,8 +5,6 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" - dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" ) var providerListFields = []string{"Id", "Name", "Description", "IssuerUri", "JwksUri"} @@ -32,10 +30,6 @@ func newProviderCommand(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command c := &identityProviderCommand{pcmd.NewAuthenticatedCLICommand(cmd, prerunner)} - dc := dynamicconfig.New(cfg, nil, nil) - _ = dc.ParseFlagsIntoConfig(cmd) - c.Hidden = !(cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false)) - cmd.AddCommand(c.newCreateCommand()) cmd.AddCommand(c.newDeleteCommand()) cmd.AddCommand(c.newDescribeCommand()) diff --git a/internal/cmd/kafka/command.go b/internal/cmd/kafka/command.go index 314c1a0bc1..fbebdb5acb 100644 --- a/internal/cmd/kafka/command.go +++ b/internal/cmd/kafka/command.go @@ -5,6 +5,8 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" + dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" + "github.com/confluentinc/cli/internal/pkg/featureflags" ) func New(cfg *v1.Config, prerunner pcmd.PreRunner, clientID string) *cobra.Command { @@ -21,10 +23,15 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner, clientID string) *cobra.Comma cmd.AddCommand(newLinkCommand(cfg, prerunner)) cmd.AddCommand(newMirrorCommand(prerunner)) cmd.AddCommand(newPartitionCommand(prerunner)) - cmd.AddCommand(newQuotaCommand(cfg, prerunner)) cmd.AddCommand(newRegionCommand(prerunner)) cmd.AddCommand(newReplicaCommand(prerunner)) cmd.AddCommand(newTopicCommand(cfg, prerunner, clientID)) + dc := dynamicconfig.New(cfg, nil, nil) + _ = dc.ParseFlagsIntoConfig(cmd) + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.client_quotas.enable", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + cmd.AddCommand(newQuotaCommand(cfg, prerunner)) + } + return cmd } diff --git a/internal/cmd/kafka/command_quota.go b/internal/cmd/kafka/command_quota.go index 8d62e5e390..c2a60850ef 100644 --- a/internal/cmd/kafka/command_quota.go +++ b/internal/cmd/kafka/command_quota.go @@ -5,8 +5,6 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" - dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/output" kafkaquotas "github.com/confluentinc/ccloud-sdk-go-v2/kafka-quotas/v1" @@ -25,11 +23,6 @@ func newQuotaCommand(config *v1.Config, prerunner pcmd.PreRunner) *cobra.Command c := "aCommand{pcmd.NewAuthenticatedStateFlagCommand(cmd, prerunner)} - dc := dynamicconfig.New(config, nil, nil) - _ = dc.ParseFlagsIntoConfig(cmd) - - c.Hidden = !(config.IsTest || launchdarkly.Manager.BoolVariation("cli.client_quotas.enable", dc.Context(), v1.CliLaunchDarklyClient, true, false)) - c.AddCommand(c.newCreateCommand()) c.AddCommand(c.newDeleteCommand()) c.AddCommand(c.newDescribeCommand()) diff --git a/internal/cmd/pipeline/command.go b/internal/cmd/pipeline/command.go index f3aaebbda2..3a2cb1a974 100644 --- a/internal/cmd/pipeline/command.go +++ b/internal/cmd/pipeline/command.go @@ -5,8 +5,6 @@ import ( pcmd "github.com/confluentinc/cli/internal/pkg/cmd" v1 "github.com/confluentinc/cli/internal/pkg/config/v1" - dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/spf13/cobra" ) @@ -70,10 +68,5 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { c.AddCommand(c.newListCommand(prerunner)) c.AddCommand(c.newUpdateCommand(prerunner)) - dc := dynamicconfig.New(cfg, nil, nil) - _ = dc.ParseFlagsIntoConfig(cmd) - - c.Hidden = !cfg.IsTest && !launchdarkly.Manager.BoolVariation("cli.stream_designer", dc.Context(), v1.CliLaunchDarklyClient, true, false) - return c.Command } diff --git a/internal/cmd/stream-share/command.go b/internal/cmd/stream-share/command.go index 217dc0d659..dcbf5caad6 100644 --- a/internal/cmd/stream-share/command.go +++ b/internal/cmd/stream-share/command.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/internal/pkg/cmd" - "github.com/confluentinc/cli/internal/pkg/config/v1" + v1 "github.com/confluentinc/cli/internal/pkg/config/v1" dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" "github.com/confluentinc/cli/internal/pkg/featureflags" ) diff --git a/internal/pkg/cmd/prerunner.go b/internal/pkg/cmd/prerunner.go index 589386245a..8789462dff 100644 --- a/internal/pkg/cmd/prerunner.go +++ b/internal/pkg/cmd/prerunner.go @@ -20,7 +20,7 @@ import ( v1 "github.com/confluentinc/cli/internal/pkg/config/v1" dynamicconfig "github.com/confluentinc/cli/internal/pkg/dynamic-config" "github.com/confluentinc/cli/internal/pkg/errors" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" + "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/form" "github.com/confluentinc/cli/internal/pkg/log" "github.com/confluentinc/cli/internal/pkg/netrc" @@ -197,8 +197,8 @@ func (r *PreRun) Anonymous(command *CLICommand, willAuthenticate bool) func(cmd } // announcement and deprecation check, print out msg ctx := dynamicconfig.NewDynamicContext(r.Config.Context(), nil, nil) - launchdarkly.PrintAnnouncements(launchdarkly.Announcements, ctx, cmd) - launchdarkly.PrintAnnouncements(launchdarkly.DeprecationNotices, ctx, cmd) + featureflags.PrintAnnouncements(featureflags.Announcements, ctx, cmd) + featureflags.PrintAnnouncements(featureflags.DeprecationNotices, ctx, cmd) } verbosity, err := cmd.Flags().GetCount("verbose") @@ -238,7 +238,7 @@ func (r *PreRun) Anonymous(command *CLICommand, willAuthenticate bool) func(cmd } func checkCliDisable(cmd *CLICommand, cfg *v1.Config) error { - ldDisableJson := launchdarkly.Manager.JsonVariation("cli.disable", cmd.Config.Context(), v1.CliLaunchDarklyClient, true, nil) + ldDisableJson := featureflags.Manager.JsonVariation("cli.disable", cmd.Config.Context(), v1.CliLaunchDarklyClient, true, nil) ldDisable, ok := ldDisableJson.(map[string]interface{}) if !ok { return nil diff --git a/internal/pkg/cmd/test_helpers.go b/internal/pkg/cmd/test_helpers.go index 2d64af9a39..3ac4320635 100644 --- a/internal/pkg/cmd/test_helpers.go +++ b/internal/pkg/cmd/test_helpers.go @@ -5,7 +5,7 @@ import ( "github.com/spf13/cobra" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" + "github.com/confluentinc/cli/internal/pkg/featureflags" ) // ExecuteCommand runs the root command with the given args, and returns the output string or an error. @@ -23,7 +23,7 @@ func ExecuteCommandC(root *cobra.Command, args ...string) (c *cobra.Command, out root.SetOut(buf) root.SetArgs(args) - launchdarkly.Init(nil, true) + featureflags.Init(nil, true) c, err = root.ExecuteC()