config: Handle aliases migration from v6 --> v7.

Fixes #1652
This commit is contained in:
Harshavardhana
2016-03-31 15:23:55 -07:00
parent ff874575e1
commit 3e205dba15
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -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 == "" ||
+1 -1
View File
@@ -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
}