From 3e205dba159f795109b2a2f8f50e592db70b755b Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 31 Mar 2016 15:19:30 -0700 Subject: [PATCH] config: Handle aliases migration from v6 --> v7. Fixes #1652 --- config-migrate.go | 16 ++++++++++++++++ config-old.go | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config-migrate.go b/config-migrate.go index 381862eb..b8fd2a68 100644 --- a/config-migrate.go +++ b/config-migrate.go @@ -334,8 +334,24 @@ func migrateConfigV6ToV7() { cfgV7 := newConfigV7() aliasIndex := 0 + + // old Aliases. + oldAliases := mcCfgV6.Data().(*configV6).Aliases + // We dropped alias support in v7. We only need to migrate host configs. for host, hostCfgV6 := range mcCfgV6.Data().(*configV6).Hosts { + // Look through old aliases, if found any matching save those entries. + for aliasName, aliasedHost := range oldAliases { + if aliasedHost == host { + cfgV7.Hosts[aliasName] = hostConfigV7{ + URL: host, + AccessKey: hostCfgV6.AccessKeyID, + SecretKey: hostCfgV6.SecretAccessKey, + API: hostCfgV6.API, + } + continue + } + } if hostCfgV6.AccessKeyID == "YOUR-ACCESS-KEY-ID-HERE" || hostCfgV6.SecretAccessKey == "YOUR-SECRET-ACCESS-KEY-HERE" || hostCfgV6.AccessKeyID == "" || diff --git a/config-old.go b/config-old.go index cb2d8fdf..5a97be09 100644 --- a/config-old.go +++ b/config-old.go @@ -178,7 +178,7 @@ type configV7 struct { // newConfigV7 - new config version '7'. func newConfigV7() *configV7 { cfg := new(configV7) - cfg.Version = globalMCConfigVersion + cfg.Version = "7" cfg.Hosts = make(map[string]hostConfigV7) return cfg }