Adding force flag to migrate auth command (#6593)

Этот коммит содержится в:
Christopher Speller
2017-06-06 11:42:53 -07:00
коммит произвёл Joram Wilander
родитель 78ebf19dc1
Коммит 04088009f8
2 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

@@ -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.") 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( userCmd.AddCommand(
userActivateCmd, userActivateCmd,
userDeactivateCmd, userDeactivateCmd,
@@ -444,8 +446,10 @@ func migrateAuthCmdF(cmd *cobra.Command, args []string) error {
return errors.New("Invalid match_field argument") return errors.New("Invalid match_field argument")
} }
forceFlag, _ := cmd.Flags().GetBool("force")
if migrate := einterfaces.GetAccountMigrationInterface(); migrate != nil { 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()) return errors.New("Error while migrating users: " + err.Error())
} else { } else {
CommandPrettyPrintln("Sucessfully migrated accounts.") CommandPrettyPrintln("Sucessfully migrated accounts.")

Просмотреть файл

@@ -6,7 +6,7 @@ package einterfaces
import "github.com/mattermost/platform/model" import "github.com/mattermost/platform/model"
type AccountMigrationInterface interface { type AccountMigrationInterface interface {
MigrateToLdap(fromAuthService string, forignUserFieldNameToMatch string) *model.AppError MigrateToLdap(fromAuthService string, forignUserFieldNameToMatch string, force bool) *model.AppError
} }
var theAccountMigrationInterface AccountMigrationInterface var theAccountMigrationInterface AccountMigrationInterface