// Migrate from config version `3` to `4`. Introduce API Signature
// field in host config. Also Use JavaScript notation for field names.
169005
func migrateConfigV3ToV4() {
	if !isMcConfigExists() {
		return
	}
	mcCfgV3, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV3())
	fatalIf(probe.NewError(e), "Unable to load mc config V2.")

	// update to newer version
	if mcCfgV3.Version() != "3" {
		return
	}

	cfgV4 := newConfigV4()
	for k, v := range mcCfgV3.Data().(*configV3).Aliases {
		cfgV4.Aliases[k] = v
	}
	// New hostConfig has API signature. All older entries were V4
	// only. So it is safe to assume V4 as default for all older
	// entries.
	// HostConfigV4 als uses JavaScript naming notation for struct JSON tags.
	for host, hostCfgV3 := range mcCfgV3.Data().(*configV3).Hosts {
		cfgV4.Hosts[host] = hostConfigV4{
			AccessKeyID:     hostCfgV3.AccessKeyID,
			SecretAccessKey: hostCfgV3.SecretAccessKey,
			Signature:       "v4",
		}
	}

	mcNewCfgV4, e := quick.NewConfig(cfgV4, nil)
	fatalIf(probe.NewError(e), "Unable to initialize quick config for config version `4`.")

	e = mcNewCfgV4.Save(mustGetMcConfigPath())
	fatalIf(probe.NewError(e), "Unable to save config version `4`.")

	console.Infof("Successfully migrated %s from version `3` to version `4`.\n", mustGetMcConfigPath())

}
999894
func migrateV2ToV3() error {
	configFile := getConfigFile()

	cv2 := &configV2{}
	_, err := Load(configFile, cv2)
	if os.IsNotExist(err) {
		return nil
	} else if err != nil {
		return fmt.Errorf("Unable to load config version ‘2’. %v", err)
	}
	if cv2.Version != "2" {
		return nil
	}

	cred, err := auth.CreateCredentials(cv2.Credentials.AccessKey, cv2.Credentials.SecretKey)
	if err != nil {
		return fmt.Errorf("Invalid credential in V2 configuration file. %v", err)
	}

	srvConfig := &configV3{}
	srvConfig.Version = "3"
	srvConfig.Addr = ":9000"
	srvConfig.Credential = cred
	srvConfig.Region = cv2.Credentials.Region
	if srvConfig.Region == "" {
		// Region needs to be set for AWS Signature V4.
		srvConfig.Region = globalMinioDefaultRegion
	}
	srvConfig.Logger.Console = consoleLoggerV1{
		Enable: true,
		Level:  "fatal",
	}
	flogger := fileLoggerV1{}
	flogger.Level = "error"
	if cv2.FileLogger.Filename != "" {
		flogger.Enable = true
		flogger.Filename = cv2.FileLogger.Filename
	}
	srvConfig.Logger.File = flogger

	slogger := syslogLoggerV3{}
	slogger.Level = "debug"
	if cv2.SyslogLogger.Addr != "" {
		slogger.Enable = true
		slogger.Addr = cv2.SyslogLogger.Addr
	}
	srvConfig.Logger.Syslog = slogger

	if err = Save(configFile, srvConfig); err != nil {
		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv2.Version, srvConfig.Version, err)
	}

	logger.Info(configMigrateMSGTemplate, configFile, cv2.Version, srvConfig.Version)
	return nil
}
908851
func (d Darwin) Migrate() error {
	return Migrate(d.driver, d.migrations, d.infoChan)
}
360562
func (d *Domain) Migrate(dconn *Connect, flags DomainMigrateFlags, dname string, uri string, bandwidth uint64) (*Domain, error) {
	var cdname *C.char
	if dname != "" {
		cdname = C.CString(dname)
		defer C.free(unsafe.Pointer(cdname))
	}
	var curi *C.char
	if uri != "" {
		curi = C.CString(uri)
		defer C.free(unsafe.Pointer(curi))
	}

	var err C.virError
	ret := C.virDomainMigrateWrapper(d.ptr, dconn.ptr, C.ulong(flags), cdname, curi, C.ulong(bandwidth), &err)
	if ret == nil {
		return nil, makeError(&err)
	}

	return &Domain{
		ptr: ret,
	}, nil
}
574809
func (c *Client) migrate(ctx context.Context, build chronograf.BuildInfo) error {
	if c.db != nil {
		// Runtime migrations
		if err := c.OrganizationsStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.SourcesStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.ServersStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.LayoutsStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.DashboardsStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.ConfigStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.BuildStore.Migrate(ctx, build); err != nil {
			return err
		}
		if err := c.MappingsStore.Migrate(ctx); err != nil {
			return err
		}
		if err := c.OrganizationConfigStore.Migrate(ctx); err != nil {
			return err
		}

		MigrateAll(c)
	}
	return nil
}
1123097
func migrateV4ToV5() error {
	configFile := getConfigFile()

	cv4 := &configV4{}
	_, err := Load(configFile, cv4)
	if os.IsNotExist(err) {
		return nil
	} else if err != nil {
		return fmt.Errorf("Unable to load config version ‘4’. %v", err)
	}
	if cv4.Version != "4" {
		return nil
	}

	// Save only the new fields, ignore the rest.
	srvConfig := &configV5{}
	srvConfig.Version = "5"
	srvConfig.Credential = cv4.Credential
	srvConfig.Region = cv4.Region
	if srvConfig.Region == "" {
		// Region needs to be set for AWS Signature Version 4.
		srvConfig.Region = globalMinioDefaultRegion
	}
	srvConfig.Logger.Console = cv4.Logger.Console
	srvConfig.Logger.File = cv4.Logger.File
	srvConfig.Logger.Syslog = cv4.Logger.Syslog
	srvConfig.Logger.AMQP.Enable = false
	srvConfig.Logger.ElasticSearch.Enable = false
	srvConfig.Logger.Redis.Enable = false

	if err = Save(configFile, srvConfig); err != nil {
		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv4.Version, srvConfig.Version, err)
	}

	logger.Info(configMigrateMSGTemplate, configFile, cv4.Version, srvConfig.Version)
	return nil
}
104579
func GetMigrations(configuration MigrationConfiguration) Migrations {
	m := Migrations{}

	// Version 0
	m = append(m, steps{ExecuteSQLFile("000-bootstrap.sql")})

	// Version 1
	m = append(m, steps{ExecuteSQLFile("001-identities-users.sql")})

	// Version 2
	m = append(m, steps{ExecuteSQLFile("002-oauth-states.sql")})

	// Version 3
	m = append(m, steps{ExecuteSQLFile("003-space-resources.sql")})

	// Version 4
	m = append(m, steps{ExecuteSQLFile("004-unique-resource-space.sql")})

	// Version 5
	m = append(m, steps{ExecuteSQLFile("005-authorization.sql")})

	// Version 6
	m = append(m, steps{ExecuteSQLFile("006-external-provider.sql")})

	// Version 7
	m = append(m, steps{ExecuteSQLFile("007-external-provider-id-index.sql")})

	// Version 8
	m = append(m, steps{ExecuteSQLFile("008-rename-token-table.sql")})

	// Version 9
	m = append(m, steps{ExecuteSQLFile("009-external-token-hard-delete.sql")})

	// Version 10
	defaultCluster := configuration.GetOpenShiftClientApiUrl()
	m = append(m, steps{ExecuteSQLFile("010-add-cluster-to-user.sql", defaultCluster)})

	// Version 11
	m = append(m, steps{ExecuteSQLFile("011-add-username-to-external-token.sql")})

	// Version 12
	m = append(m, steps{ExecuteSQLFile("012-hide-email.sql")})

	// Version 13
	m = append(m, steps{ExecuteSQLFile("013-add-email-verified.sql")})

	// Version 14
	m = append(m, steps{ExecuteSQLFile("014-add-user-feature-level.sql")})

	// Version 15
	m = append(m, steps{ExecuteSQLFile("015-clear-resources-create-resource-types.sql")})

	// Version 16
	m = append(m, steps{ExecuteSQLFile("016-add-state-to-auth-state-reference.sql")})

	// Version 17
	m = append(m, steps{ExecuteSQLFile("017-feature-level-not-null.sql")})

	// Version 18
	m = append(m, steps{ExecuteSQLFile("018-convert-user-feature-level.sql")})

	// Version 19
	m = append(m, steps{ExecuteSQLFile("019-authorization-part-2.sql")})

	// Version 20
	m = append(m, steps{ExecuteSQLFile("020-add-response-mode-to-auth-state-reference.sql")})

	// Version 21
	m = append(m, steps{ExecuteSQLFile("021-organizations-list-create.sql")})

	// Version 22
	m = append(m, steps{ExecuteSQLFile("022-add-deprovisioned-to-user.sql")})

	// Version 23
	m = append(m, steps{ExecuteSQLFile("023-resource-type-index.sql")})

	// Version 24
	m = append(m, steps{ExecuteSQLFile("024-role-mapping-and-team-and-group-identities.sql")})

	// Version 25
	m = append(m, steps{ExecuteSQLFile("025-fix-feature-level.sql")})

	// Version 26
	m = append(m, steps{ExecuteSQLFile("026-identities-users-indexes.sql")})

	// Version 27
	m = append(m, steps{ExecuteSQLFile("027-invitations.sql")})

	// Version 28
	m = append(m, steps{ExecuteSQLFile("028-make-organization-names-unique.sql")})

	// Version 29
	m = append(m, steps{ExecuteSQLFile("029-add-space-resourcetype.sql")})

	// Version 30
	m = append(m, steps{ExecuteSQLFile("030-add-team-admin-role.sql")})

	// Version 31
	m = append(m, steps{ExecuteSQLFile("031-clean-up-roles-scopes.sql")})

	// Version 32
	m = append(m, steps{ExecuteSQLFile("032-invitation-code.sql")})

	// Version 33
	m = append(m, steps{ExecuteSQLFile("033-drop-space-resources.sql")})

	// Version 34
	m = append(m, steps{ExecuteSQLFile("034-rename-token-table.sql")})

	// Version 35
	m = append(m, steps{ExecuteSQLFile("035-unique_constraint_default_role_mapping.sql")})

	// Version 36
	m = append(m, steps{ExecuteSQLFile("036-token-privileges.sql")})

	// Version 37
	m = append(m, steps{ExecuteSQLFile("037-invitation-redirect-url.sql")})

	// Version 38
	m = append(m, steps{ExecuteSQLFile("038-admin-console-resource.sql")})

	// Version 39
	m = append(m, steps{ExecuteSQLFile("039-resource-type-alter.sql")})

	// Version 40
	m = append(m, steps{ExecuteSQLFile("040-deferrable-constraints.sql")})

	// Version 41
	m = append(m, steps{ExecuteSQLFile("041-identity-role-index.sql")})

	// Version 42
	m = append(m, steps{ExecuteSQLFile("042-token-index.sql")})

	// Version 43
	m = append(m, steps{ExecuteSQLFile("043-add-admin-console-resource.sql")})

	// Version 44
	m = append(m, steps{ExecuteSQLFile("044-user-active.sql")})

	// Version 45
	m = append(m, steps{ExecuteSQLFile("045-identity-last-active.sql")})

	// Version 46
	m = append(m, steps{ExecuteSQLFile("046-identity-last-active-default.sql")})

	// Version 47
	m = append(m, steps{ExecuteSQLFile("047-add-user-banned-column.sql")})

	// Version 48
	m = append(m, steps{ExecuteSQLFile("048-identity-deactivation-notification.sql")})

	// Version 49
	m = append(m, steps{ExecuteSQLFile("049-user-banned-index.sql")})

	// Version 50
	m = append(m, steps{ExecuteSQLFile("050-worker-lock.sql")})

	// Version 51
	m = append(m, steps{ExecuteSQLFile("051-identity-deactivation-scheduled.sql")})

	// Version N
	//
	// In order to add an upgrade, simply append an array of MigrationFunc to the
	// the end of the "migrations" slice. The version numbers are determined by
	// the index in the array. The following code in comments show how you can
	// do a migration in 3 steps. If one of the steps fails, the others are not
	// executed.
	// If something goes wrong during the migration, all you need to do is return
	// an error that is not nil.

	/*
		m = append(m, steps{
			func(db *sql.Tx) error {
				// Execute random go code
				return nil
			},
			ExecuteSQLFile("YOUR_OWN_FILE.sql"),
			func(db *sql.Tx) error {
				// Execute random go code
				return nil
			},
		})
	*/

	return m
}
789267
func MigrateOldConfig(oldConfig []byte) ([]byte, error) {
	newConfig := [][]byte{}

	gvkmap, err := kubeadmutil.SplitYAMLDocuments(oldConfig)
	if err != nil {
		return []byte{}, err
	}

	gvks := []schema.GroupVersionKind{}
	for gvk := range gvkmap {
		gvks = append(gvks, gvk)
	}

	// Migrate InitConfiguration and ClusterConfiguration if there are any in the config
	if kubeadmutil.GroupVersionKindsHasInitConfiguration(gvks...) || kubeadmutil.GroupVersionKindsHasClusterConfiguration(gvks...) {
		o, err := documentMapToInitConfiguration(gvkmap, true)
		if err != nil {
			return []byte{}, err
		}
		b, err := MarshalKubeadmConfigObject(o)
		if err != nil {
			return []byte{}, err
		}
		newConfig = append(newConfig, b)
	}

	// Migrate JoinConfiguration if there is any
	if kubeadmutil.GroupVersionKindsHasJoinConfiguration(gvks...) {
		o, err := documentMapToJoinConfiguration(gvkmap, true)
		if err != nil {
			return []byte{}, err
		}
		b, err := MarshalKubeadmConfigObject(o)
		if err != nil {
			return []byte{}, err
		}
		newConfig = append(newConfig, b)
	}

	return bytes.Join(newConfig, []byte(constants.YAMLDocumentSeparator)), nil
}
139210
func migrateV6ToV7() error {
	configFile := getConfigFile()

	cv6 := &configV6{}
	_, err := Load(configFile, cv6)
	if os.IsNotExist(err) {
		return nil
	} else if err != nil {
		return fmt.Errorf("Unable to load config version ‘6’. %v", err)
	}
	if cv6.Version != "6" {
		return nil
	}

	// Save only the new fields, ignore the rest.
	srvConfig := &serverConfigV7{}
	srvConfig.Version = "7"
	srvConfig.Credential = cv6.Credential
	srvConfig.Region = cv6.Region
	if srvConfig.Region == "" {
		// Region needs to be set for AWS Signature Version 4.
		srvConfig.Region = globalMinioDefaultRegion
	}
	srvConfig.Logger.Console = cv6.Logger.Console
	srvConfig.Logger.File = cv6.Logger.File
	srvConfig.Logger.Syslog = cv6.Logger.Syslog
	srvConfig.Notify.AMQP = make(map[string]target.AMQPArgs)
	srvConfig.Notify.ElasticSearch = make(map[string]target.ElasticsearchArgs)
	srvConfig.Notify.Redis = make(map[string]target.RedisArgs)
	if len(cv6.Notify.AMQP) == 0 {
		srvConfig.Notify.AMQP["1"] = target.AMQPArgs{}
	} else {
		srvConfig.Notify.AMQP = cv6.Notify.AMQP
	}
	if len(cv6.Notify.ElasticSearch) == 0 {
		srvConfig.Notify.ElasticSearch["1"] = target.ElasticsearchArgs{}
	} else {
		srvConfig.Notify.ElasticSearch = cv6.Notify.ElasticSearch
	}
	if len(cv6.Notify.Redis) == 0 {
		srvConfig.Notify.Redis["1"] = target.RedisArgs{}
	} else {
		srvConfig.Notify.Redis = cv6.Notify.Redis
	}

	if err = Save(configFile, srvConfig); err != nil {
		return fmt.Errorf("Failed to migrate config from ‘%s’ to ‘%s’. %v", cv6.Version, srvConfig.Version, err)
	}

	logger.Info(configMigrateMSGTemplate, configFile, cv6.Version, srvConfig.Version)
	return nil
}
456024
func migrateConfigV4ToV5() {
	if !isMcConfigExists() {
		return
	}
	mcCfgV4, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV4())
	fatalIf(probe.NewError(e), "Unable to load mc config V4.")

	// update to newer version
	if mcCfgV4.Version() != "4" {
		return
	}

	cfgV5 := newConfigV5()
	for k, v := range mcCfgV4.Data().(*configV4).Aliases {
		cfgV5.Aliases[k] = v
	}
	for host, hostCfgV4 := range mcCfgV4.Data().(*configV4).Hosts {
		cfgV5.Hosts[host] = hostConfigV5{
			AccessKeyID:     hostCfgV4.AccessKeyID,
			SecretAccessKey: hostCfgV4.SecretAccessKey,
			API:             "v4", // Rename from .Signature to .API
		}
	}

	mcNewCfgV5, e := quick.NewConfig(cfgV5, nil)
	fatalIf(probe.NewError(e), "Unable to initialize quick config for config version `5`.")

	e = mcNewCfgV5.Save(mustGetMcConfigPath())
	fatalIf(probe.NewError(e), "Unable to save config version `5`.")

	console.Infof("Successfully migrated %s from version `4` to version `5`.\n", mustGetMcConfigPath())
}
1237178
func (d *Domain) Migrate3(dconn *Connect, params *DomainMigrateParameters, flags DomainMigrateFlags) (*Domain, error) {

	info := getMigrateParameterFieldInfo(params)
	cparams, cnparams, gerr := typedParamsPackNew(info)
	if gerr != nil {
		return nil, gerr
	}

	defer C.virTypedParamsFree(cparams, cnparams)

	var err C.virError
	ret := C.virDomainMigrate3Wrapper(d.ptr, dconn.ptr, cparams, C.uint(cnparams), C.uint(flags), &err)
	if ret == nil {
		return nil, makeError(&err)
	}

	return &Domain{
		ptr: ret,
	}, nil
}
174004
func AddVersion(prefix string) storage.MigrateFunction {
	return func(client *redis.Client, key string, obj map[string]string) (string, map[string]string, error) {
		return "2.4.1", obj, nil
	}
}
861705
func (d config) Version() string {
	st := structs.New(d.data)
	f := st.Field("Version")
	return f.Value().(string)
}
1294942
func (p *remotePrevAlloc) Migrate(ctx context.Context, dest *allocdir.AllocDir) error {
	if !p.migrate {
		// Volume wasn't configured to be migrated, return early
		return nil
	}

	p.waitingLock.Lock()
	p.migrating = true
	p.waitingLock.Unlock()
	defer func() {
		p.waitingLock.Lock()
		p.migrating = false
		p.waitingLock.Unlock()
	}()

	p.logger.Debug("copying from remote previous alloc")

	if p.nodeID == "" {
		// NodeID couldn't be found; likely alloc was GC'd
		p.logger.Warn("unable to migrate data from previous alloc; previous alloc may have been GC'd")
		return nil
	}

	addr, err := p.getNodeAddr(ctx, p.nodeID)
	if err != nil {
		return err
	}

	prevAllocDir, err := p.migrateAllocDir(ctx, addr)
	if err != nil {
		return err
	}

	if err := dest.Move(prevAllocDir, p.tasks); err != nil {
		// cleanup on error
		prevAllocDir.Destroy()
		return err
	}

	if err := prevAllocDir.Destroy(); err != nil {
		p.logger.Error("error destroying alloc dir",
			"error", err, "previous_alloc_dir", prevAllocDir.AllocDir)
	}
	return nil
}
361954
func migrateConfigV101ToV2() {
	if !isMcConfigExists() {
		return
	}
	mcCfgV101, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV101())
	fatalIf(probe.NewError(e), "Unable to load config version `1.0.1`.")

	// update to newer version
	if mcCfgV101.Version() != "1.0.1" {
		return
	}

	cfgV2 := newConfigV2()

	// Copy aliases.
	for k, v := range mcCfgV101.Data().(*configV101).Aliases {
		cfgV2.Aliases[k] = v
	}

	// Copy hosts.
	for k, hostCfgV101 := range mcCfgV101.Data().(*configV101).Hosts {
		cfgV2.Hosts[k] = hostConfigV2{
			AccessKeyID:     hostCfgV101.AccessKeyID,
			SecretAccessKey: hostCfgV101.SecretAccessKey,
		}
	}

	mcCfgV2, e := quick.NewConfig(cfgV2, nil)
	fatalIf(probe.NewError(e), "Unable to initialize quick config for config version `2`.")

	e = mcCfgV2.Save(mustGetMcConfigPath())
	fatalIf(probe.NewError(e), "Unable to save config version `2`.")

	console.Infof("Successfully migrated %s from version `1.0.1` to version `2`.\n", mustGetMcConfigPath())
}
898383
func migrateConfigV7ToV8() {
	if !isMcConfigExists() {
		return
	}

	mcCfgV7, e := quick.LoadConfig(mustGetMcConfigPath(), nil, newConfigV7())
	fatalIf(probe.NewError(e), "Unable to load mc config V7.")

	if mcCfgV7.Version() != "7" {
		return
	}

	cfgV8 := newConfigV8()
	// We dropped alias support in v7. We only need to migrate host configs.
	for host, hostCfgV7 := range mcCfgV7.Data().(*configV7).Hosts {
		// Ignore 'player', 'play' and 'dl' aliases.
		if host == "player" || host == "dl" || host == "play" {
			continue
		}
		hostCfgV8 := hostConfigV8{}
		hostCfgV8.URL = hostCfgV7.URL
		hostCfgV8.AccessKey = hostCfgV7.AccessKey
		hostCfgV8.SecretKey = hostCfgV7.SecretKey
		hostCfgV8.API = hostCfgV7.API
		cfgV8.Hosts[host] = hostCfgV8
	}
	// Load default settings.
	cfgV8.loadDefaults()
	mcNewCfgV8, e := quick.NewConfig(cfgV8, nil)
	fatalIf(probe.NewError(e), "Unable to initialize quick config for config version `8`.")

	e = mcNewCfgV8.Save(mustGetMcConfigPath())
	fatalIf(probe.NewError(e), "Unable to save config version `8`.")

	console.Infof("Successfully migrated %s from version `7` to version `8`.\n", mustGetMcConfigPath())
}
1166738
func Convert_config_Key_To_v1_Key(in *config.Key, out *Key, s conversion.Scope) error {
	return autoConvert_config_Key_To_v1_Key(in, out, s)
}