allow caseless API signature in config (#1675)
This commit is contained in:
committed by
Harshavardhana
parent
3d04e56228
commit
d5cb19aeab
+1
-1
@@ -92,7 +92,7 @@ func newFactory() func(config *Config) (Client, *probe.Error) {
|
||||
if api, found = clientCache[confSum]; !found {
|
||||
// Not found. Instantiate a new minio
|
||||
var e error
|
||||
if config.Signature == "S3v2" {
|
||||
if strings.ToUpper(config.Signature) == "S3V2" {
|
||||
// if Signature version '2' use NewV2 directly.
|
||||
api, e = minio.NewV2(hostName, config.AccessKey, config.SecretKey, inSecure)
|
||||
} else {
|
||||
|
||||
+3
-5
@@ -165,11 +165,9 @@ func checkConfigHostAddSyntax(ctx *cli.Context) {
|
||||
"Invalid secret key ‘"+secretKey+"’.")
|
||||
}
|
||||
|
||||
switch api {
|
||||
case "S3v2", "S3v4", "":
|
||||
default:
|
||||
if api != "" && !isValidAPI(api) { // Empty value set to default "S3v4".
|
||||
fatalIf(errInvalidArgument().Trace(api),
|
||||
"Unrecognized API signature. Valid options are ‘[ S3v4, S3v2 ]’.")
|
||||
"Unrecognized API signature. Valid options are ‘[S3v4, S3v2]’.")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -214,7 +212,7 @@ func mainConfigHost(ctx *cli.Context) {
|
||||
accessKey := args.Get(2)
|
||||
secretKey := args.Get(3)
|
||||
api := args.Get(4)
|
||||
if strings.TrimSpace(api) == "" {
|
||||
if api == "" {
|
||||
api = "S3v4"
|
||||
}
|
||||
hostCfg := hostConfigV8{
|
||||
|
||||
@@ -53,3 +53,13 @@ func isValidHostURL(hostURL string) bool {
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
// isValidAPI - Validates if API signature string of supported type.
|
||||
func isValidAPI(api string) bool {
|
||||
switch strings.ToLower(api) {
|
||||
case "s3v2", "s3v4":
|
||||
return true
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user