Allow only account-key updates for azure tier (#13276)

This commit is contained in:
Krishnan Parthasarathi 2021-09-23 02:34:31 -07:00 committed by GitHub
parent f4d1b7c603
commit 3e4efff73d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -146,7 +146,7 @@ func (config *TierConfigMgr) Edit(ctx context.Context, tierName string, creds ma
return errTierNotFound return errTierNotFound
} }
newCfg := config.Tiers[tierName] cfg := config.Tiers[tierName]
switch tierType { switch tierType {
case madmin.S3: case madmin.S3:
if (creds.AccessKey == "" || creds.SecretKey == "") && !creds.AWSRole { if (creds.AccessKey == "" || creds.SecretKey == "") && !creds.AWSRole {
@ -154,30 +154,29 @@ func (config *TierConfigMgr) Edit(ctx context.Context, tierName string, creds ma
} }
switch { switch {
case creds.AWSRole: case creds.AWSRole:
newCfg.S3.AWSRole = true cfg.S3.AWSRole = true
default: default:
newCfg.S3.AccessKey = creds.AccessKey cfg.S3.AccessKey = creds.AccessKey
newCfg.S3.SecretKey = creds.SecretKey cfg.S3.SecretKey = creds.SecretKey
} }
case madmin.Azure: case madmin.Azure:
if creds.AccessKey == "" || creds.SecretKey == "" { if creds.SecretKey == "" {
return errTierInsufficientCreds return errTierInsufficientCreds
} }
newCfg.Azure.AccountName = creds.AccessKey cfg.Azure.AccountKey = creds.SecretKey
newCfg.Azure.AccountKey = creds.SecretKey
case madmin.GCS: case madmin.GCS:
if creds.CredsJSON == nil { if creds.CredsJSON == nil {
return errTierInsufficientCreds return errTierInsufficientCreds
} }
newCfg.GCS.Creds = base64.URLEncoding.EncodeToString(creds.CredsJSON) cfg.GCS.Creds = base64.URLEncoding.EncodeToString(creds.CredsJSON)
} }
d, err := newWarmBackend(ctx, newCfg) d, err := newWarmBackend(ctx, cfg)
if err != nil { if err != nil {
return err return err
} }
config.Tiers[tierName] = newCfg config.Tiers[tierName] = cfg
config.drivercache[tierName] = d config.drivercache[tierName] = d
return nil return nil
} }