mirror of
https://github.com/minio/minio.git
synced 2025-01-12 15:33:22 -05:00
Make every backend responsible for parsing its own arguments, fixes #4293
This commit is contained in:
parent
2d814e340f
commit
bf55591c64
@ -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
|
||||
|
@ -161,7 +161,20 @@ type gcsGateway struct {
|
||||
}
|
||||
|
||||
// newGCSGateway returns gcs gatewaylayer
|
||||
func newGCSGateway(endpoint string, projectID, secretKey string, secure bool) (GatewayLayer, error) {
|
||||
func newGCSGateway(args []string) (GatewayLayer, error) {
|
||||
if len(args) != 1 {
|
||||
return nil, fmt.Errorf("ProjectID expected")
|
||||
}
|
||||
|
||||
profile := "default"
|
||||
// TODO: don't know where to set profile yet
|
||||
_ = profile
|
||||
|
||||
endpoint := "storage.googleapis.com"
|
||||
secure := true
|
||||
|
||||
projectID := args[0]
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Creates a client.
|
||||
@ -170,10 +183,6 @@ func newGCSGateway(endpoint string, projectID, secretKey string, secure bool) (G
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if endpoint == "" {
|
||||
endpoint = "storage.googleapis.com"
|
||||
}
|
||||
|
||||
anonClient, err := minio.NewCore(endpoint, "", "", secure)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -181,7 +190,7 @@ func newGCSGateway(endpoint string, projectID, secretKey string, secure bool) (G
|
||||
|
||||
return &gcsGateway{
|
||||
client: client,
|
||||
projectID: "minio-166400",
|
||||
projectID: projectID,
|
||||
ctx: ctx,
|
||||
anonClient: anonClient,
|
||||
}, nil
|
||||
|
@ -18,8 +18,10 @@ package cmd
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
||||
minio "github.com/minio/minio-go"
|
||||
@ -97,12 +99,23 @@ type s3Objects struct {
|
||||
}
|
||||
|
||||
// newS3Gateway returns s3 gatewaylayer
|
||||
func newS3Gateway(endpoint string, accessKey, secretKey string, secure bool) (GatewayLayer, error) {
|
||||
func newS3Gateway(args []string) (GatewayLayer, error) {
|
||||
endpoint, secure, err := parseGatewayEndpoint(args[0])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if endpoint == "" {
|
||||
endpoint = "s3.amazonaws.com"
|
||||
secure = true
|
||||
}
|
||||
|
||||
accessKey := os.Getenv("MINIO_ACCESS_KEY")
|
||||
secretKey := os.Getenv("MINIO_SECRET_KEY")
|
||||
if accessKey == "" || secretKey == "" {
|
||||
return nil, errors.New("No S3 access and secret key")
|
||||
}
|
||||
|
||||
// Initialize minio client object.
|
||||
client, err := minio.NewCore(endpoint, accessKey, secretKey, secure)
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user