From aa5f71150e89680a960a4c842399055d8c248853 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Fri, 2 Dec 2022 16:54:27 +0000 Subject: [PATCH 1/3] CLOUDP-148788: [AtlasCLI] cutover command is using orgId instead of projectId --- internal/cli/atlas/livemigrations/cutover.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cli/atlas/livemigrations/cutover.go b/internal/cli/atlas/livemigrations/cutover.go index c8ed8d16ee..a37da34510 100644 --- a/internal/cli/atlas/livemigrations/cutover.go +++ b/internal/cli/atlas/livemigrations/cutover.go @@ -43,7 +43,7 @@ func (opts *CutoverOpts) initStore(ctx context.Context) func() error { } func (opts *CutoverOpts) Run() error { - r, err := opts.store.CreateLiveMigrationCutover(opts.ConfigOrgID(), opts.liveMigrationID) + r, err := opts.store.CreateLiveMigrationCutover(opts.ConfigProjectID(), opts.liveMigrationID) if err != nil { return err } @@ -60,7 +60,7 @@ func CutoverBuilder() *cobra.Command { Long: "Your API Key must have the Organization Owner role to successfully run this command.", PreRunE: func(cmd *cobra.Command, args []string) error { return opts.PreRunE( - opts.ValidateOrgID, + opts.ValidateProjectID, opts.initStore(cmd.Context()), opts.InitOutput(cmd.OutOrStdout(), cutoverTemplate), ) From edb910a596b27da3f24e555e232190cee1cb46e3 Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Mon, 5 Dec 2022 09:48:27 +0000 Subject: [PATCH 2/3] Addressed PR comment --- docs/atlascli/command/atlas-liveMigrations-create.txt | 8 ++++---- .../command/atlas-liveMigrations-validation-create.txt | 8 ++++---- .../command/mongocli-atlas-liveMigrations-create.txt | 8 ++++---- .../mongocli-atlas-liveMigrations-validation-create.txt | 8 ++++---- internal/cli/atlas/livemigrations/create_test.go | 2 +- .../atlas/livemigrations/options/live_migrations_opts.go | 2 +- .../cli/atlas/livemigrations/validation/create_test.go | 2 +- internal/store/live_migrations.go | 4 ++-- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/docs/atlascli/command/atlas-liveMigrations-create.txt b/docs/atlascli/command/atlas-liveMigrations-create.txt index 709d881739..29f1b04ab8 100644 --- a/docs/atlascli/command/atlas-liveMigrations-create.txt +++ b/docs/atlascli/command/atlas-liveMigrations-create.txt @@ -56,14 +56,14 @@ Options - strings - true - List of hosts running the MongoDB Agent that can transfer your MongoDB data from the source (Cloud Manager or Ops Manager) to destination (Atlas) deployments. Each live migration process uses its own dedicated migration host. - * - --orgId - - string - - false - - Organization ID to use. Overrides the settings in the configuration file or environment variable. * - -o, --output - string - false - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --projectId + - string + - false + - Project ID to use. Overrides the settings in the configuration file or environment variable. * - --sourceCACertificatePath - string - false diff --git a/docs/atlascli/command/atlas-liveMigrations-validation-create.txt b/docs/atlascli/command/atlas-liveMigrations-validation-create.txt index 1d0ebfb8cd..efd93ce380 100644 --- a/docs/atlascli/command/atlas-liveMigrations-validation-create.txt +++ b/docs/atlascli/command/atlas-liveMigrations-validation-create.txt @@ -56,14 +56,14 @@ Options - strings - true - List of hosts running the MongoDB Agent that can transfer your MongoDB data from the source (Cloud Manager or Ops Manager) to destination (Atlas) deployments. Each live migration process uses its own dedicated migration host. - * - --orgId - - string - - false - - Organization ID to use. Overrides the settings in the configuration file or environment variable. * - -o, --output - string - false - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --projectId + - string + - false + - Project ID to use. Overrides the settings in the configuration file or environment variable. * - --sourceCACertificatePath - string - false diff --git a/docs/mongocli/command/mongocli-atlas-liveMigrations-create.txt b/docs/mongocli/command/mongocli-atlas-liveMigrations-create.txt index f03b00b8be..3e23160980 100644 --- a/docs/mongocli/command/mongocli-atlas-liveMigrations-create.txt +++ b/docs/mongocli/command/mongocli-atlas-liveMigrations-create.txt @@ -56,14 +56,14 @@ Options - strings - true - List of hosts running the MongoDB Agent that can transfer your MongoDB data from the source (Cloud Manager or Ops Manager) to destination (Atlas) deployments. Each live migration process uses its own dedicated migration host. - * - --orgId - - string - - false - - Organization ID to use. Overrides the settings in the configuration file or environment variable. * - -o, --output - string - false - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --projectId + - string + - false + - Project ID to use. Overrides the settings in the configuration file or environment variable. * - --sourceCACertificatePath - string - false diff --git a/docs/mongocli/command/mongocli-atlas-liveMigrations-validation-create.txt b/docs/mongocli/command/mongocli-atlas-liveMigrations-validation-create.txt index 465315fb43..f9d078a12c 100644 --- a/docs/mongocli/command/mongocli-atlas-liveMigrations-validation-create.txt +++ b/docs/mongocli/command/mongocli-atlas-liveMigrations-validation-create.txt @@ -56,14 +56,14 @@ Options - strings - true - List of hosts running the MongoDB Agent that can transfer your MongoDB data from the source (Cloud Manager or Ops Manager) to destination (Atlas) deployments. Each live migration process uses its own dedicated migration host. - * - --orgId - - string - - false - - Organization ID to use. Overrides the settings in the configuration file or environment variable. * - -o, --output - string - false - Output format. Valid values are json, json-path, go-template, or go-template-file. + * - --projectId + - string + - false + - Project ID to use. Overrides the settings in the configuration file or environment variable. * - --sourceCACertificatePath - string - false diff --git a/internal/cli/atlas/livemigrations/create_test.go b/internal/cli/atlas/livemigrations/create_test.go index 7fac88a566..da4450bd75 100644 --- a/internal/cli/atlas/livemigrations/create_test.go +++ b/internal/cli/atlas/livemigrations/create_test.go @@ -65,7 +65,7 @@ func TestCreateBuilder(t *testing.T) { CreateBuilder(), 0, []string{ - flag.OrgID, + flag.ProjectID, flag.LiveMigrationSourceClusterName, flag.LiveMigrationSourceProjectID, flag.LiveMigrationSourceUsername, diff --git a/internal/cli/atlas/livemigrations/options/live_migrations_opts.go b/internal/cli/atlas/livemigrations/options/live_migrations_opts.go index bcd692dccc..e8b4be82a1 100644 --- a/internal/cli/atlas/livemigrations/options/live_migrations_opts.go +++ b/internal/cli/atlas/livemigrations/options/live_migrations_opts.go @@ -138,7 +138,7 @@ func (opts *LiveMigrationsOpts) Validate() error { } func (opts *LiveMigrationsOpts) GenerateFlags(cmd *cobra.Command) { - cmd.Flags().StringVar(&opts.OrgID, flag.OrgID, "", usage.OrgID) + cmd.Flags().StringVar(&opts.ProjectID, flag.ProjectID, "", usage.ProjectID) cmd.Flags().StringVar(&opts.SourceClusterName, flag.LiveMigrationSourceClusterName, "", usage.LiveMigrationSourceClusterName) cmd.Flags().StringVar(&opts.SourceProjectID, flag.LiveMigrationSourceProjectID, "", usage.LiveMigrationSourceProjectID) cmd.Flags().StringVarP(&opts.SourceUsername, flag.LiveMigrationSourceUsername, flag.UsernameShort, "", usage.LiveMigrationSourceUsername) diff --git a/internal/cli/atlas/livemigrations/validation/create_test.go b/internal/cli/atlas/livemigrations/validation/create_test.go index 4b01750a64..bae1fc83e2 100644 --- a/internal/cli/atlas/livemigrations/validation/create_test.go +++ b/internal/cli/atlas/livemigrations/validation/create_test.go @@ -64,7 +64,7 @@ func TestCreateBuilder(t *testing.T) { CreateBuilder(), 0, []string{ - flag.OrgID, + flag.ProjectID, flag.LiveMigrationSourceClusterName, flag.LiveMigrationSourceProjectID, flag.LiveMigrationSourceUsername, diff --git a/internal/store/live_migrations.go b/internal/store/live_migrations.go index 9088f7ddba..9124387a45 100644 --- a/internal/store/live_migrations.go +++ b/internal/store/live_migrations.go @@ -32,7 +32,7 @@ type LiveMigrationDescriber interface { LiveMigrationDescribe(string, string) (*atlas.LiveMigration, error) } -// LiveMigrationCreate encapsulate the logic to manage different cloud providers. +// LiveMigrationCreate encapsulates the logic to manage different cloud providers. func (s *Store) LiveMigrationCreate(groupID string, liveMigration *atlas.LiveMigration) (*atlas.LiveMigration, error) { switch s.service { case config.CloudService: @@ -43,7 +43,7 @@ func (s *Store) LiveMigrationCreate(groupID string, liveMigration *atlas.LiveMig } } -// LiveMigrationCreate encapsulate the logic to manage different cloud providers. +// LiveMigrationDescribe encapsulates the logic to manage different cloud providers. func (s *Store) LiveMigrationDescribe(groupID, migrationID string) (*atlas.LiveMigration, error) { switch s.service { case config.CloudService: From ca8eb98a626ac4e394530aef15fe91a76b65e28e Mon Sep 17 00:00:00 2001 From: andreaangiolillo Date: Mon, 5 Dec 2022 12:11:50 +0000 Subject: [PATCH 3/3] Addressed Gustavo's comment --- .../cli/atlas/livemigrations/options/live_migrations_opts.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/internal/cli/atlas/livemigrations/options/live_migrations_opts.go b/internal/cli/atlas/livemigrations/options/live_migrations_opts.go index e8b4be82a1..0b957f368a 100644 --- a/internal/cli/atlas/livemigrations/options/live_migrations_opts.go +++ b/internal/cli/atlas/livemigrations/options/live_migrations_opts.go @@ -125,9 +125,6 @@ func (opts *LiveMigrationsOpts) Validate() error { return err } - if opts.SourceManagedAuthentication && opts.SourceUsername != "" { - return fmt.Errorf("--%s and --%s are exclusive", flag.LiveMigrationSourceManagedAuthentication, flag.LiveMigrationSourceUsername) - } if !opts.SourceManagedAuthentication && opts.SourceUsername == "" { return fmt.Errorf("MongoDB Automation is not managing authentication, --%s must be set", flag.LiveMigrationSourceUsername) } @@ -152,6 +149,8 @@ func (opts *LiveMigrationsOpts) GenerateFlags(cmd *cobra.Command) { cmd.Flags().BoolVar(&opts.Force, flag.Force, false, usage.Force) cmd.Flags().StringVarP(&opts.Output, flag.Output, flag.OutputShort, "", usage.FormatOut) + cmd.MarkFlagsMutuallyExclusive(flag.LiveMigrationSourceManagedAuthentication, flag.LiveMigrationSourceUsername) + _ = cmd.MarkFlagRequired(flag.LiveMigrationSourceClusterName) _ = cmd.MarkFlagRequired(flag.LiveMigrationSourceProjectID) _ = cmd.MarkFlagRequired(flag.ClusterName)