Simplify the steps to make changes to config.json (#5186)

This change introduces following simplified steps to follow 
during config migration.

```
 // Steps to move from version N to version N+1
 // 1. Add new struct serverConfigVN+1 in config-versions.go
 // 2. Set configCurrentVersion to "N+1"
 // 3. Set serverConfigCurrent to serverConfigVN+1
 // 4. Add new migration function (ex. func migrateVNToVN+1()) in config-migrate.go
 // 5. Call migrateVNToVN+1() from migrateConfig() in config-migrate.go
 // 6. Make changes in config-current_test.go for any test change
```
This commit is contained in:
Krishna Srinivas
2017-11-29 13:12:47 -08:00
committed by Harshavardhana
parent 98d07210e7
commit 14e6c5ec08
60 changed files with 324 additions and 314 deletions

View File

@@ -183,12 +183,12 @@ func (adminAPI adminAPIHandlers) ServiceCredentialsHandler(w http.ResponseWriter
}
// Update local credentials in memory.
prevCred := serverConfig.SetCredential(creds)
prevCred := globalServerConfig.SetCredential(creds)
// Save credentials to config file
if err = serverConfig.Save(); err != nil {
if err = globalServerConfig.Save(); err != nil {
// Save the current creds when failed to update.
serverConfig.SetCredential(prevCred)
globalServerConfig.SetCredential(prevCred)
errorIf(err, "Unable to update the config with new credentials.")
writeErrorResponse(w, ErrInternalError, r.URL)
@@ -985,7 +985,7 @@ func (adminAPI adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http
return
}
var config serverConfigV20
var config serverConfig
err = json.Unmarshal(configBytes, &config)
if err != nil {
@@ -995,7 +995,7 @@ func (adminAPI adminAPIHandlers) SetConfigHandler(w http.ResponseWriter, r *http
}
if globalIsEnvCreds {
creds := serverConfig.GetCredential()
creds := globalServerConfig.GetCredential()
if config.Credential.AccessKey != creds.AccessKey ||
config.Credential.SecretKey != creds.SecretKey {
writeErrorResponse(w, ErrAdminCredentialsMismatch, r.URL)