control cmds: Extract access and secret keys from URL if specified (#3109)

This commit is contained in:
Anis Elleuch
2016-10-27 02:42:12 +01:00
committed by Harshavardhana
parent e9c45102b0
commit f7c20b97a1
3 changed files with 36 additions and 6 deletions
+12 -2
View File
@@ -191,9 +191,19 @@ func healControl(ctx *cli.Context) {
parsedURL, err := url.Parse(ctx.Args().Get(0))
fatalIf(err, "Unable to parse URL %s", ctx.Args().Get(0))
accessKey := serverConfig.GetCredential().AccessKeyID
secretKey := serverConfig.GetCredential().SecretAccessKey
// Username and password specified in URL will override prior configuration
if parsedURL.User != nil {
accessKey = parsedURL.User.Username()
if key, set := parsedURL.User.Password(); set {
secretKey = key
}
}
authCfg := &authConfig{
accessKey: serverConfig.GetCredential().AccessKeyID,
secretKey: serverConfig.GetCredential().SecretAccessKey,
accessKey: accessKey,
secretKey: secretKey,
secureConn: parsedURL.Scheme == "https",
address: parsedURL.Host,
path: path.Join(reservedBucket, controlPath),