Make every backend responsible for parsing its own arguments, fixes #4293

This commit is contained in:
Remco Verhoef
2017-05-08 15:42:48 -07:00
committed by Harshavardhana
parent 2d814e340f
commit bf55591c64
3 changed files with 45 additions and 9 deletions

View File

@@ -20,11 +20,13 @@ import (
"crypto/md5"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
"net/http"
"net/url"
"os"
"strconv"
"strings"
"sync"
@@ -153,11 +155,23 @@ func azureToObjectError(err error, params ...string) error {
return e
}
// Inits azure blob storage client and returns azureObjects.
func newAzureLayer(endPoint string, account, key string, secure bool) (GatewayLayer, error) {
// Inits azure blob storage client and returns AzureObjects.
func newAzureLayer(args []string) (GatewayLayer, error) {
endPoint, secure, err := parseGatewayEndpoint(args[0])
if err != nil {
return nil, err
}
if endPoint == "" {
endPoint = storage.DefaultBaseURL
}
account := os.Getenv("MINIO_ACCESS_KEY")
key := os.Getenv("MINIO_SECRET_KEY")
if account == "" || key == "" {
return nil, errors.New("No Azure account and key set")
}
c, err := storage.NewClient(account, key, endPoint, globalAzureAPIVersion, secure)
if err != nil {
return &azureObjects{}, err