gateway/gcs: Complete minio browser support for gcs. (#4552)

Fixes #4460
master
Harshavardhana 8 years ago committed by GitHub
parent 3928c1e14c
commit 5a78266821
  1. 5
      cmd/gateway-azure.go
  2. 5
      cmd/gateway-main.go
  3. 4
      cmd/gateway-s3.go
  4. 12
      cmd/web-handlers.go

@ -20,7 +20,6 @@ import (
"crypto/md5"
"encoding/base64"
"encoding/hex"
"errors"
"fmt"
"hash"
"io"
@ -169,10 +168,6 @@ func newAzureLayer(host string) (GatewayLayer, error) {
}
creds := serverConfig.GetCredential()
if !creds.IsValid() && !globalIsEnvCreds {
return nil, errors.New("Azure backend account and secret keys should be set through ENVs")
}
c, err := storage.NewClient(creds.AccessKey, creds.SecretKey, endpoint, globalAzureAPIVersion, secure)
if err != nil {
return &azureObjects{}, err

@ -290,6 +290,11 @@ func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
// Handle common env vars.
handleCommonEnvVars()
// Validate if we have access, secret set through environment.
if !globalIsEnvCreds {
fatalIf(fmt.Errorf("Access and Secret keys should be set through ENVs for backend [%s]", backendType), "")
}
// Create certs path.
fatalIf(createConfigDir(), "Unable to create configuration directories.")

@ -17,7 +17,6 @@
package cmd
import (
"errors"
"io"
"net/http"
"path"
@ -120,9 +119,6 @@ func newS3Gateway(host string) (GatewayLayer, error) {
}
creds := serverConfig.GetCredential()
if !creds.IsValid() && !globalIsEnvCreds {
return nil, errors.New("S3 backend account and secret keys should be set through ENVs")
}
// Initialize minio client object.
client, err := minio.NewCore(endpoint, creds.AccessKey, creds.SecretKey, secure)

@ -690,13 +690,15 @@ func getBucketAccessPolicy(objAPI ObjectLayer, bucketName string) (policy.Bucket
policyInfo, err = layer.GetBucketPolicies(bucketName)
case *azureObjects:
policyInfo, err = layer.GetBucketPolicies(bucketName)
case *gcsGateway:
policyInfo, err = layer.GetBucketPolicies(bucketName)
default:
policyInfo, err = readBucketAccessPolicy(objAPI, bucketName)
}
return policyInfo, err
}
// GetBucketPolicy - get bucket policy.
// GetBucketPolicy - get bucket policy for the requested prefix.
func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolicyArgs, reply *GetBucketPolicyRep) error {
objectAPI := web.ObjectAPI()
if objectAPI == nil {
@ -707,10 +709,13 @@ func (web *webAPIHandlers) GetBucketPolicy(r *http.Request, args *GetBucketPolic
return toJSONError(errAuthentication)
}
policyInfo, err := readBucketAccessPolicy(objectAPI, args.BucketName)
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
if err != nil {
_, ok := errorCause(err).(PolicyNotFound)
if !ok {
return toJSONError(err, args.BucketName)
}
}
reply.UIVersion = browser.UIVersion
reply.Policy = policy.GetPolicy(policyInfo.Statements, args.BucketName, args.Prefix)
@ -745,8 +750,8 @@ func (web *webAPIHandlers) ListAllBucketPolicies(r *http.Request, args *ListAllB
if !isHTTPRequestValid(r) {
return toJSONError(errAuthentication)
}
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
if err != nil {
_, ok := errorCause(err).(PolicyNotFound)
if !ok {
@ -791,7 +796,6 @@ func (web *webAPIHandlers) SetBucketPolicy(r *http.Request, args *SetBucketPolic
}
var policyInfo, err = getBucketAccessPolicy(objectAPI, args.BucketName)
if err != nil {
if _, ok := errorCause(err).(PolicyNotFound); !ok {
return toJSONError(err, args.BucketName)

Loading…
Cancel
Save