From d2f6ff458b42f482f8f52bc672776a43ac880f28 Mon Sep 17 00:00:00 2001 From: MuweiHe Date: Mon, 10 Oct 2022 16:39:26 -0700 Subject: [PATCH 1/5] Update command.go --- internal/cmd/iam/command.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/internal/cmd/iam/command.go b/internal/cmd/iam/command.go index 70c91d50d2..6ca61dd8aa 100644 --- a/internal/cmd/iam/command.go +++ b/internal/cmd/iam/command.go @@ -1,10 +1,14 @@ package iam import ( + "fmt" + "github.com/spf13/cobra" 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 command struct { @@ -34,9 +38,15 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { prerunner: prerunner, } + dc := dynamicconfig.New(cfg, nil, nil) + _ = dc.ParseFlagsIntoConfig(cmd) + if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + fmt.Println(cfg.IsTest) + fmt.Println(launchdarkly.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)) From e1cdca1901b2fefef257958a5054001c5b11202a Mon Sep 17 00:00:00 2001 From: MuweiHe Date: Mon, 10 Oct 2022 19:03:49 -0700 Subject: [PATCH 2/5] modify other 3 commands --- internal/cmd/api-key/command_describe.go | 4 ++-- internal/cmd/api-key/command_list.go | 4 ++-- internal/cmd/command.go | 20 +++++++++++++------- internal/cmd/iam/command.go | 4 ---- internal/cmd/kafka/command.go | 9 ++++++++- internal/cmd/kafka/command_quota.go | 7 ------- internal/cmd/stream-share/command.go | 6 +++--- internal/pkg/cmd/prerunner_test.go | 4 ++-- 8 files changed, 30 insertions(+), 28 deletions(-) diff --git a/internal/cmd/api-key/command_describe.go b/internal/cmd/api-key/command_describe.go index 45a297b1b9..d7c3513a3c 100644 --- a/internal/cmd/api-key/command_describe.go +++ b/internal/cmd/api-key/command_describe.go @@ -10,7 +10,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" - "github.com/confluentinc/cli/internal/pkg/featureflags" + launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/output" ) @@ -59,7 +59,7 @@ func (c *command) describe(cmd *cobra.Command, args []string) error { resources := []apikeysv2.ObjectReference{apiKey.Spec.GetResource()} // Check if multicluster keys are enabled, and if so check the resources field - if featureflags.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { + if launchdarkly.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { resources = apiKey.Spec.GetResources() } diff --git a/internal/cmd/api-key/command_list.go b/internal/cmd/api-key/command_list.go index 0d5b51fe9d..05f132e662 100644 --- a/internal/cmd/api-key/command_list.go +++ b/internal/cmd/api-key/command_list.go @@ -14,7 +14,7 @@ import ( v1 "github.com/confluentinc/cli/internal/pkg/config/v1" "github.com/confluentinc/cli/internal/pkg/errors" "github.com/confluentinc/cli/internal/pkg/examples" - "github.com/confluentinc/cli/internal/pkg/featureflags" + launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/output" "github.com/confluentinc/cli/internal/pkg/resource" ) @@ -139,7 +139,7 @@ func (c *command) list(cmd *cobra.Command, _ []string) error { resources := []apikeysv2.ObjectReference{apiKey.Spec.GetResource()} // Check if multicluster keys are enabled, and if so check the resources field - if featureflags.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { + if launchdarkly.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { resources = apiKey.Spec.GetResources() } diff --git a/internal/cmd/command.go b/internal/cmd/command.go index e228269618..377ebfea94 100644 --- a/internal/cmd/command.go +++ b/internal/cmd/command.go @@ -40,7 +40,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" - "github.com/confluentinc/cli/internal/pkg/featureflags" + launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/form" "github.com/confluentinc/cli/internal/pkg/help" "github.com/confluentinc/cli/internal/pkg/netrc" @@ -74,7 +74,7 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { loginCredentialsManager := pauth.NewLoginCredentialsManager(netrcHandler, form.NewPrompt(os.Stdin), ccloudClient) loginOrganizationManager := pauth.NewLoginOrganizationManagerImpl() mdsClientManager := &pauth.MDSClientManagerImpl{} - featureflags.Init(cfg.Version, cfg.IsTest) + launchdarkly.Init(cfg.Version, cfg.IsTest) cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { pcmd.LabelRequiredFlags(cmd) @@ -116,10 +116,16 @@ 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)) + ctx := dynamicconfig.NewDynamicContext(cfg.Context(), nil, nil) + dc := dynamicconfig.New(cfg, nil, nil) + _ = dc.ParseFlagsIntoConfig(cmd) + if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false) { + cmd.AddCommand(streamshare.New(cfg, prerunner)) + } + changeDefaults(cmd, cfg) deprecateCommandsAndFlags(cmd, cfg) return cmd @@ -212,14 +218,14 @@ func getCloudClient(cfg *v1.Config, ccloudClientFactory pauth.CCloudClientFactor func deprecateCommandsAndFlags(cmd *cobra.Command, cfg *v1.Config) { ctx := dynamicconfig.NewDynamicContext(cfg.Context(), nil, nil) - deprecatedCmds := featureflags.Manager.JsonVariation(featureflags.DeprecationNotices, ctx, v1.CliLaunchDarklyClient, true, []interface{}{}) - cmdToFlagsAndMsg := featureflags.GetAnnouncementsOrDeprecation(deprecatedCmds) + deprecatedCmds := launchdarkly.Manager.JsonVariation(launchdarkly.DeprecationNotices, ctx, v1.CliLaunchDarklyClient, true, []interface{}{}) + cmdToFlagsAndMsg := launchdarkly.GetAnnouncementsOrDeprecation(deprecatedCmds) for name, flagsAndMsg := range cmdToFlagsAndMsg { if cmd, _, err := cmd.Find(strings.Split(name, " ")); err == nil { if flagsAndMsg.Flags == nil { - featureflags.DeprecateCommandTree(cmd) + launchdarkly.DeprecateCommandTree(cmd) } else { - featureflags.DeprecateFlags(cmd, flagsAndMsg.Flags) + launchdarkly.DeprecateFlags(cmd, flagsAndMsg.Flags) } } } diff --git a/internal/cmd/iam/command.go b/internal/cmd/iam/command.go index 6ca61dd8aa..9a44c0d482 100644 --- a/internal/cmd/iam/command.go +++ b/internal/cmd/iam/command.go @@ -1,8 +1,6 @@ package iam import ( - "fmt" - "github.com/spf13/cobra" pcmd "github.com/confluentinc/cli/internal/pkg/cmd" @@ -41,8 +39,6 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { dc := dynamicconfig.New(cfg, nil, nil) _ = dc.ParseFlagsIntoConfig(cmd) if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false) { - fmt.Println(cfg.IsTest) - fmt.Println(launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false)) c.AddCommand(newPoolCommand(cfg, c.prerunner)) c.AddCommand(newProviderCommand(cfg, c.prerunner)) } diff --git a/internal/cmd/kafka/command.go b/internal/cmd/kafka/command.go index 314c1a0bc1..a803147e46 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" + launchdarkly "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 || launchdarkly.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/stream-share/command.go b/internal/cmd/stream-share/command.go index 217dc0d659..af4f8333dd 100644 --- a/internal/cmd/stream-share/command.go +++ b/internal/cmd/stream-share/command.go @@ -4,9 +4,9 @@ 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" + launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" ) type command struct { @@ -21,7 +21,7 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { Aliases: []string{"ss"}, Short: "Manage stream shares.", Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireCloudLogin}, - Hidden: !cfg.IsTest && !featureflags.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false), + Hidden: !cfg.IsTest && !launchdarkly.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false), } c := &command{pcmd.NewAuthenticatedCLICommand(cmd, prerunner)} diff --git a/internal/pkg/cmd/prerunner_test.go b/internal/pkg/cmd/prerunner_test.go index b0c2b091b8..7de2a139fa 100644 --- a/internal/pkg/cmd/prerunner_test.go +++ b/internal/pkg/cmd/prerunner_test.go @@ -21,7 +21,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" - "github.com/confluentinc/cli/internal/pkg/featureflags" + launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/form" "github.com/confluentinc/cli/internal/pkg/log" pmock "github.com/confluentinc/cli/internal/pkg/mock" @@ -115,7 +115,7 @@ func getPreRunBase() *pcmd.PreRun { } func TestPreRun_Anonymous_SetLoggingLevel(t *testing.T) { - featureflags.Init(nil, true) + launchdarkly.Init(nil, true) tests := map[string]log.Level{ "": log.ERROR, From f8169cb5a9c2694d7fd05c39fd1c890959896466 Mon Sep 17 00:00:00 2001 From: MuweiHe Date: Tue, 11 Oct 2022 17:31:58 -0700 Subject: [PATCH 3/5] comments --- internal/cmd/api-key/command_describe.go | 4 ++-- internal/cmd/api-key/command_list.go | 4 ++-- internal/cmd/cloud-signup/command.go | 4 ++-- internal/cmd/command.go | 15 +++++++-------- internal/cmd/iam/command.go | 4 ++-- internal/cmd/iam/command_pool.go | 4 ++-- internal/cmd/iam/command_provider.go | 4 ++-- internal/cmd/kafka/command.go | 4 ++-- internal/cmd/pipeline/command.go | 4 ++-- internal/cmd/stream-share/command.go | 4 ++-- internal/pkg/cmd/prerunner.go | 8 ++++---- internal/pkg/cmd/prerunner_test.go | 4 ++-- internal/pkg/cmd/test_helpers.go | 4 ++-- 13 files changed, 33 insertions(+), 34 deletions(-) diff --git a/internal/cmd/api-key/command_describe.go b/internal/cmd/api-key/command_describe.go index d7c3513a3c..45a297b1b9 100644 --- a/internal/cmd/api-key/command_describe.go +++ b/internal/cmd/api-key/command_describe.go @@ -10,7 +10,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/output" ) @@ -59,7 +59,7 @@ func (c *command) describe(cmd *cobra.Command, args []string) error { resources := []apikeysv2.ObjectReference{apiKey.Spec.GetResource()} // Check if multicluster keys are enabled, and if so check the resources field - if launchdarkly.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { + if featureflags.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { resources = apiKey.Spec.GetResources() } diff --git a/internal/cmd/api-key/command_list.go b/internal/cmd/api-key/command_list.go index 05f132e662..0d5b51fe9d 100644 --- a/internal/cmd/api-key/command_list.go +++ b/internal/cmd/api-key/command_list.go @@ -14,7 +14,7 @@ import ( v1 "github.com/confluentinc/cli/internal/pkg/config/v1" "github.com/confluentinc/cli/internal/pkg/errors" "github.com/confluentinc/cli/internal/pkg/examples" - launchdarkly "github.com/confluentinc/cli/internal/pkg/featureflags" + "github.com/confluentinc/cli/internal/pkg/featureflags" "github.com/confluentinc/cli/internal/pkg/output" "github.com/confluentinc/cli/internal/pkg/resource" ) @@ -139,7 +139,7 @@ func (c *command) list(cmd *cobra.Command, _ []string) error { resources := []apikeysv2.ObjectReference{apiKey.Spec.GetResource()} // Check if multicluster keys are enabled, and if so check the resources field - if launchdarkly.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { + if featureflags.Manager.BoolVariation("cli.multicluster-api-keys.enable", c.Context, v1.CliLaunchDarklyClient, true, false) { resources = apiKey.Spec.GetResources() } 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 377ebfea94..5cc913496d 100644 --- a/internal/cmd/command.go +++ b/internal/cmd/command.go @@ -40,7 +40,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/help" "github.com/confluentinc/cli/internal/pkg/netrc" @@ -74,7 +74,7 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { loginCredentialsManager := pauth.NewLoginCredentialsManager(netrcHandler, form.NewPrompt(os.Stdin), ccloudClient) loginOrganizationManager := pauth.NewLoginOrganizationManagerImpl() mdsClientManager := &pauth.MDSClientManagerImpl{} - launchdarkly.Init(cfg.Version, cfg.IsTest) + featureflags.Init(cfg.Version, cfg.IsTest) cmd.SetHelpFunc(func(cmd *cobra.Command, args []string) { pcmd.LabelRequiredFlags(cmd) @@ -119,10 +119,9 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { cmd.AddCommand(update.New(prerunner, cfg.Version, updateClient)) cmd.AddCommand(version.New(prerunner, cfg.Version)) - ctx := dynamicconfig.NewDynamicContext(cfg.Context(), nil, nil) dc := dynamicconfig.New(cfg, nil, nil) _ = dc.ParseFlagsIntoConfig(cmd) - if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false) { + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.cdx", dc.Context(), v1.CliLaunchDarklyClient, true, false) { cmd.AddCommand(streamshare.New(cfg, prerunner)) } @@ -218,14 +217,14 @@ func getCloudClient(cfg *v1.Config, ccloudClientFactory pauth.CCloudClientFactor func deprecateCommandsAndFlags(cmd *cobra.Command, cfg *v1.Config) { ctx := dynamicconfig.NewDynamicContext(cfg.Context(), nil, nil) - deprecatedCmds := launchdarkly.Manager.JsonVariation(launchdarkly.DeprecationNotices, ctx, v1.CliLaunchDarklyClient, true, []interface{}{}) - cmdToFlagsAndMsg := launchdarkly.GetAnnouncementsOrDeprecation(deprecatedCmds) + deprecatedCmds := featureflags.Manager.JsonVariation(featureflags.DeprecationNotices, ctx, v1.CliLaunchDarklyClient, true, []interface{}{}) + cmdToFlagsAndMsg := featureflags.GetAnnouncementsOrDeprecation(deprecatedCmds) for name, flagsAndMsg := range cmdToFlagsAndMsg { if cmd, _, err := cmd.Find(strings.Split(name, " ")); err == nil { if flagsAndMsg.Flags == nil { - launchdarkly.DeprecateCommandTree(cmd) + featureflags.DeprecateCommandTree(cmd) } else { - launchdarkly.DeprecateFlags(cmd, flagsAndMsg.Flags) + featureflags.DeprecateFlags(cmd, flagsAndMsg.Flags) } } } diff --git a/internal/cmd/iam/command.go b/internal/cmd/iam/command.go index 9a44c0d482..29210a86b4 100644 --- a/internal/cmd/iam/command.go +++ b/internal/cmd/iam/command.go @@ -6,7 +6,7 @@ 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/featureflags" ) type command struct { @@ -38,7 +38,7 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { dc := dynamicconfig.New(cfg, nil, nil) _ = dc.ParseFlagsIntoConfig(cmd) - if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + 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)) } diff --git a/internal/cmd/iam/command_pool.go b/internal/cmd/iam/command_pool.go index 2fa7fcfd36..c8a37ddc3b 100644 --- a/internal/cmd/iam/command_pool.go +++ b/internal/cmd/iam/command_pool.go @@ -6,7 +6,7 @@ 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/featureflags" ) type identityPoolCommand struct { @@ -32,7 +32,7 @@ func newPoolCommand(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { 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)) + c.Hidden = !(cfg.IsTest || featureflags.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false)) cmd.AddCommand(c.newCreateCommand()) cmd.AddCommand(c.newDeleteCommand()) diff --git a/internal/cmd/iam/command_provider.go b/internal/cmd/iam/command_provider.go index 236edd6973..8d5e2b171b 100644 --- a/internal/cmd/iam/command_provider.go +++ b/internal/cmd/iam/command_provider.go @@ -6,7 +6,7 @@ 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/featureflags" ) var providerListFields = []string{"Id", "Name", "Description", "IssuerUri", "JwksUri"} @@ -34,7 +34,7 @@ func newProviderCommand(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command 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)) + c.Hidden = !(cfg.IsTest || featureflags.Manager.BoolVariation("cli.identity-provider", dc.Context(), v1.CliLaunchDarklyClient, true, false)) cmd.AddCommand(c.newCreateCommand()) cmd.AddCommand(c.newDeleteCommand()) diff --git a/internal/cmd/kafka/command.go b/internal/cmd/kafka/command.go index a803147e46..fbebdb5acb 100644 --- a/internal/cmd/kafka/command.go +++ b/internal/cmd/kafka/command.go @@ -6,7 +6,7 @@ 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/featureflags" ) func New(cfg *v1.Config, prerunner pcmd.PreRunner, clientID string) *cobra.Command { @@ -29,7 +29,7 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner, clientID string) *cobra.Comma dc := dynamicconfig.New(cfg, nil, nil) _ = dc.ParseFlagsIntoConfig(cmd) - if cfg.IsTest || launchdarkly.Manager.BoolVariation("cli.client_quotas.enable", dc.Context(), v1.CliLaunchDarklyClient, true, false) { + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.client_quotas.enable", dc.Context(), v1.CliLaunchDarklyClient, true, false) { cmd.AddCommand(newQuotaCommand(cfg, prerunner)) } diff --git a/internal/cmd/pipeline/command.go b/internal/cmd/pipeline/command.go index f3aaebbda2..ac8483a394 100644 --- a/internal/cmd/pipeline/command.go +++ b/internal/cmd/pipeline/command.go @@ -6,7 +6,7 @@ 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/featureflags" "github.com/spf13/cobra" ) @@ -73,7 +73,7 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { 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) + c.Hidden = !cfg.IsTest && !featureflags.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 af4f8333dd..dcbf5caad6 100644 --- a/internal/cmd/stream-share/command.go +++ b/internal/cmd/stream-share/command.go @@ -6,7 +6,7 @@ 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/featureflags" ) type command struct { @@ -21,7 +21,7 @@ func New(cfg *v1.Config, prerunner pcmd.PreRunner) *cobra.Command { Aliases: []string{"ss"}, Short: "Manage stream shares.", Annotations: map[string]string{pcmd.RunRequirement: pcmd.RequireCloudLogin}, - Hidden: !cfg.IsTest && !launchdarkly.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false), + Hidden: !cfg.IsTest && !featureflags.Manager.BoolVariation("cli.cdx", ctx, v1.CliLaunchDarklyClient, true, false), } c := &command{pcmd.NewAuthenticatedCLICommand(cmd, prerunner)} 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/prerunner_test.go b/internal/pkg/cmd/prerunner_test.go index 7de2a139fa..b0c2b091b8 100644 --- a/internal/pkg/cmd/prerunner_test.go +++ b/internal/pkg/cmd/prerunner_test.go @@ -21,7 +21,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" pmock "github.com/confluentinc/cli/internal/pkg/mock" @@ -115,7 +115,7 @@ func getPreRunBase() *pcmd.PreRun { } func TestPreRun_Anonymous_SetLoggingLevel(t *testing.T) { - launchdarkly.Init(nil, true) + featureflags.Init(nil, true) tests := map[string]log.Level{ "": log.ERROR, 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() From 7aac9f4b600c406910801da07c4e6e5a81d6fe6c Mon Sep 17 00:00:00 2001 From: MuweiHe Date: Tue, 11 Oct 2022 19:28:54 -0700 Subject: [PATCH 4/5] comments ii --- internal/cmd/command.go | 4 +++- internal/cmd/iam/command_pool.go | 6 ------ internal/cmd/iam/command_provider.go | 6 ------ internal/cmd/pipeline/command.go | 7 ------- 4 files changed, 3 insertions(+), 20 deletions(-) diff --git a/internal/cmd/command.go b/internal/cmd/command.go index 5cc913496d..195a0fb205 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)) @@ -124,6 +123,9 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { 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) diff --git a/internal/cmd/iam/command_pool.go b/internal/cmd/iam/command_pool.go index c8a37ddc3b..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" - "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 || featureflags.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 8d5e2b171b..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" - "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 || featureflags.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/pipeline/command.go b/internal/cmd/pipeline/command.go index ac8483a394..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" - "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 && !featureflags.Manager.BoolVariation("cli.stream_designer", dc.Context(), v1.CliLaunchDarklyClient, true, false) - return c.Command } From 53643d1bc4a8fe2dbf7f45435d0785a151db0df2 Mon Sep 17 00:00:00 2001 From: MuweiHe <83249359+MuweiHe@users.noreply.github.com> Date: Wed, 12 Oct 2022 10:35:24 -0700 Subject: [PATCH 5/5] Update internal/cmd/command.go Co-authored-by: Brian Strauch --- internal/cmd/command.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cmd/command.go b/internal/cmd/command.go index 195a0fb205..289b979104 100644 --- a/internal/cmd/command.go +++ b/internal/cmd/command.go @@ -123,7 +123,7 @@ func NewConfluentCommand(cfg *v1.Config) *cobra.Command { 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) { + if cfg.IsTest || featureflags.Manager.BoolVariation("cli.stream_designer", dc.Context(), v1.CliLaunchDarklyClient, true, false) { cmd.AddCommand(pipeline.New(cfg, prerunner)) }