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

@@ -137,7 +137,7 @@ func (web *webAPIHandlers) MakeBucket(r *http.Request, args *MakeBucketArgs, rep
}
defer bucketLock.Unlock()
if err := objectAPI.MakeBucketWithLocation(args.BucketName, serverConfig.GetRegion()); err != nil {
if err := objectAPI.MakeBucketWithLocation(args.BucketName, globalServerConfig.GetRegion()); err != nil {
return toJSONError(err, args.BucketName)
}
@@ -409,12 +409,12 @@ func (web *webAPIHandlers) SetAuth(r *http.Request, args *SetAuthArgs, reply *Se
errsMap := updateCredsOnPeers(creds)
// Update local credentials
prevCred := serverConfig.SetCredential(creds)
prevCred := globalServerConfig.SetCredential(creds)
// Persist updated credentials.
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)
errsMap[globalMinioAddr] = err
}
@@ -467,7 +467,7 @@ func (web *webAPIHandlers) GetAuth(r *http.Request, args *WebGenericArgs, reply
if !isHTTPRequestValid(r) {
return toJSONError(errAuthentication)
}
creds := serverConfig.GetCredential()
creds := globalServerConfig.GetCredential()
reply.AccessKey = creds.AccessKey
reply.SecretKey = creds.SecretKey
reply.UIVersion = browser.UIVersion
@@ -486,7 +486,7 @@ func (web *webAPIHandlers) CreateURLToken(r *http.Request, args *WebGenericArgs,
return toJSONError(errAuthentication)
}
creds := serverConfig.GetCredential()
creds := globalServerConfig.GetCredential()
token, err := authenticateURL(creds.AccessKey, creds.SecretKey)
if err != nil {
@@ -925,8 +925,8 @@ func (web *webAPIHandlers) PresignedGet(r *http.Request, args *PresignedGetArgs,
// Returns presigned url for GET method.
func presignedGet(host, bucket, object string, expiry int64) string {
cred := serverConfig.GetCredential()
region := serverConfig.GetRegion()
cred := globalServerConfig.GetCredential()
region := globalServerConfig.GetRegion()
accessKey := cred.AccessKey
secretKey := cred.SecretKey