Cleanup and update the PR with the master branch.

master
Remco Verhoef 8 years ago committed by Harshavardhana
parent a76556ec1b
commit 0dab038858
  1. 2
      cmd/gateway-azure.go
  2. 2
      cmd/gateway-gcs-anonymous.go
  3. 6
      cmd/gateway-gcs.go
  4. 5
      cmd/gateway-handlers.go
  5. 29
      cmd/gateway-main.go
  6. 2
      cmd/gateway-s3.go
  7. 1053
      cmd/gcs/gateway-gcs-url.go

@ -166,7 +166,7 @@ func newAzureLayer(args cli.Args) (GatewayLayer, error) {
secure := true
// If user provided some parameters
if len(args) > 0 {
if args.Present() {
endPoint, secure, err = parseGatewayEndpoint(args.First())
if err != nil {
return nil, err

@ -94,7 +94,7 @@ func (l *gcsGateway) AnonGetObjectInfo(bucket string, object string) (objInfo Ob
objInfo.UserDefined["Content-Encoding"] = resp.Header.Get("Content-Encoding")
}
objInfo.UserDefined["Content-Type"] = resp.Header.Get("Content-Type")
objInfo.MD5Sum = resp.Header.Get("Etag")
objInfo.ETag = resp.Header.Get("Etag")
objInfo.ModTime = t
objInfo.Name = object
objInfo.Size = contentLength

@ -351,7 +351,7 @@ func (l *gcsGateway) ListObjects(bucket string, prefix string, marker string, de
Bucket: attrs.Bucket,
ModTime: attrs.Updated,
Size: attrs.Size,
MD5Sum: hex.EncodeToString(attrs.MD5),
ETag: hex.EncodeToString(attrs.MD5),
UserDefined: attrs.Metadata,
ContentType: attrs.ContentType,
ContentEncoding: attrs.ContentEncoding,
@ -443,7 +443,7 @@ func fromGCSObjectInfo(attrs *storage.ObjectAttrs) ObjectInfo {
Bucket: attrs.Bucket,
ModTime: attrs.Updated,
Size: attrs.Size,
MD5Sum: hex.EncodeToString(attrs.MD5),
ETag: hex.EncodeToString(attrs.MD5),
UserDefined: attrs.Metadata,
ContentType: attrs.ContentType,
ContentEncoding: attrs.ContentEncoding,
@ -691,7 +691,7 @@ func (l *gcsGateway) PutObjectPart(bucket string, key string, uploadID string, p
return PartInfo{
PartNumber: partID,
LastModified: info.ModTime,
ETag: info.MD5Sum,
ETag: info.ETag,
Size: info.Size,
}, err
}

@ -657,10 +657,7 @@ func (api gatewayAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Re
// reads body which has been read already. So only validating
// region here.
serverRegion := serverConfig.GetRegion()
if serverRegion == "" {
// we will only validate the region
// when the region has been explicitely set
} else if serverRegion != location {
if serverRegion != "" && serverRegion != location {
writeErrorResponse(w, ErrInvalidRegion, r.URL)
return
}

@ -178,17 +178,6 @@ const (
// Add more backends here.
)
// GatewayFn returns the GatewayLayer for the backend
type GatewayFn func(cli.Args) (GatewayLayer, error)
var (
backends = map[gatewayBackend]GatewayFn{
azureBackend: newAzureLayer,
s3Backend: newS3Gateway,
gcsBackend: newGCSGateway,
}
)
// Returns access and secretkey set from environment variables.
func mustGetGatewayConfigFromEnv() (string, string, string) {
// Fetch access keys from environment variables.
@ -225,18 +214,17 @@ func mustSetBrowserSettingFromEnv() {
// Supported backend types are
//
// - Azure Blob Storage.
// - S3 Object Storage.
// - AWS S3.
// - Google Cloud Storage.
// - Add your favorite backend here.
func newGatewayLayer(backendType gatewayBackend, endpoint, accessKey, secretKey string, secure bool) (GatewayLayer, error) {
func newGatewayLayer(backendType string, args cli.Args) (GatewayLayer, error) {
switch gatewayBackend(backendType) {
case azureBackend:
return newAzureLayer(endpoint, accessKey, secretKey, secure)
return newAzureLayer(args)
case s3Backend:
return newS3Gateway(endpoint, accessKey, secretKey, secure)
return newS3Gateway(args)
case gcsBackend:
return newGCSGateway(endpoint, accessKey, secretKey, secure)
return newGCSGateway(args)
}
return nil, fmt.Errorf("Unrecognized backend type %s", backendType)
@ -371,15 +359,10 @@ func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
err := validateGatewayArguments(serverAddr, endpointAddr)
fatalIf(err, "Invalid argument")
// Second argument is endpoint. If no endpoint is specified then the
// gateway implementation should use a default setting.
endPoint, secure, err := parseGatewayEndpoint(endpointAddr)
fatalIf(err, "Unable to parse endpoint")
// Create certs path for SSL configuration.
fatalIf(createConfigDir(), "Unable to create configuration directory")
newObject, err := newGatewayLayer(backendType, endPoint, accessKey, secretKey, secure)
newObject, err := newGatewayLayer(backendType, ctx.Args()[1:])
fatalIf(err, "Unable to initialize gateway layer")
initNSLock(false) // Enable local namespace lock.

@ -110,7 +110,7 @@ func newS3Gateway(args cli.Args) (GatewayLayer, error) {
secure := true
// Check if user provided some parameters
if len(args) > 0 {
if args.Present() {
// Override default params if the endpoint is provided
endpoint, secure, err = parseGatewayEndpoint(args.First())
if err != nil {

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save