From 04088009f843c863d9f54b2a2c5b45b7f7e3ba9e Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Tue, 6 Jun 2017 11:42:53 -0700 Subject: Adding force flag to migrate auth command (#6593) --- cmd/platform/user.go | 6 +++++- einterfaces/account_migration.go | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/platform/user.go b/cmd/platform/user.go index 74e71ebe3..93fce3867 100644 --- a/cmd/platform/user.go +++ b/cmd/platform/user.go @@ -141,6 +141,8 @@ func init() { deleteAllUsersCmd.Flags().Bool("confirm", false, "Confirm you really want to delete the user and a DB backup has been performed.") + migrateAuthCmd.Flags().Bool("force", false, "Force the migration to occour even if there are duplicates on the LDAP server. Duplicates will not be migrated.") + userCmd.AddCommand( userActivateCmd, userDeactivateCmd, @@ -444,8 +446,10 @@ func migrateAuthCmdF(cmd *cobra.Command, args []string) error { return errors.New("Invalid match_field argument") } + forceFlag, _ := cmd.Flags().GetBool("force") + if migrate := einterfaces.GetAccountMigrationInterface(); migrate != nil { - if err := migrate.MigrateToLdap(fromAuth, matchField); err != nil { + if err := migrate.MigrateToLdap(fromAuth, matchField, forceFlag); err != nil { return errors.New("Error while migrating users: " + err.Error()) } else { CommandPrettyPrintln("Sucessfully migrated accounts.") diff --git a/einterfaces/account_migration.go b/einterfaces/account_migration.go index a52b5e348..c9534ab68 100644 --- a/einterfaces/account_migration.go +++ b/einterfaces/account_migration.go @@ -6,7 +6,7 @@ package einterfaces import "github.com/mattermost/platform/model" type AccountMigrationInterface interface { - MigrateToLdap(fromAuthService string, forignUserFieldNameToMatch string) *model.AppError + MigrateToLdap(fromAuthService string, forignUserFieldNameToMatch string, force bool) *model.AppError } var theAccountMigrationInterface AccountMigrationInterface -- cgit v1.2.3-1-g7c22