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 secure := true
// If user provided some parameters // If user provided some parameters
if len(args) > 0 { if args.Present() {
endPoint, secure, err = parseGatewayEndpoint(args.First()) endPoint, secure, err = parseGatewayEndpoint(args.First())
if err != nil { if err != nil {
return nil, err 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-Encoding"] = resp.Header.Get("Content-Encoding")
} }
objInfo.UserDefined["Content-Type"] = resp.Header.Get("Content-Type") 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.ModTime = t
objInfo.Name = object objInfo.Name = object
objInfo.Size = contentLength objInfo.Size = contentLength

@ -351,7 +351,7 @@ func (l *gcsGateway) ListObjects(bucket string, prefix string, marker string, de
Bucket: attrs.Bucket, Bucket: attrs.Bucket,
ModTime: attrs.Updated, ModTime: attrs.Updated,
Size: attrs.Size, Size: attrs.Size,
MD5Sum: hex.EncodeToString(attrs.MD5), ETag: hex.EncodeToString(attrs.MD5),
UserDefined: attrs.Metadata, UserDefined: attrs.Metadata,
ContentType: attrs.ContentType, ContentType: attrs.ContentType,
ContentEncoding: attrs.ContentEncoding, ContentEncoding: attrs.ContentEncoding,
@ -443,7 +443,7 @@ func fromGCSObjectInfo(attrs *storage.ObjectAttrs) ObjectInfo {
Bucket: attrs.Bucket, Bucket: attrs.Bucket,
ModTime: attrs.Updated, ModTime: attrs.Updated,
Size: attrs.Size, Size: attrs.Size,
MD5Sum: hex.EncodeToString(attrs.MD5), ETag: hex.EncodeToString(attrs.MD5),
UserDefined: attrs.Metadata, UserDefined: attrs.Metadata,
ContentType: attrs.ContentType, ContentType: attrs.ContentType,
ContentEncoding: attrs.ContentEncoding, ContentEncoding: attrs.ContentEncoding,
@ -691,7 +691,7 @@ func (l *gcsGateway) PutObjectPart(bucket string, key string, uploadID string, p
return PartInfo{ return PartInfo{
PartNumber: partID, PartNumber: partID,
LastModified: info.ModTime, LastModified: info.ModTime,
ETag: info.MD5Sum, ETag: info.ETag,
Size: info.Size, Size: info.Size,
}, err }, 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 // reads body which has been read already. So only validating
// region here. // region here.
serverRegion := serverConfig.GetRegion() serverRegion := serverConfig.GetRegion()
if serverRegion == "" { if serverRegion != "" && serverRegion != location {
// we will only validate the region
// when the region has been explicitely set
} else if serverRegion != location {
writeErrorResponse(w, ErrInvalidRegion, r.URL) writeErrorResponse(w, ErrInvalidRegion, r.URL)
return return
} }

@ -178,17 +178,6 @@ const (
// Add more backends here. // 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. // Returns access and secretkey set from environment variables.
func mustGetGatewayConfigFromEnv() (string, string, string) { func mustGetGatewayConfigFromEnv() (string, string, string) {
// Fetch access keys from environment variables. // Fetch access keys from environment variables.
@ -225,18 +214,17 @@ func mustSetBrowserSettingFromEnv() {
// Supported backend types are // Supported backend types are
// //
// - Azure Blob Storage. // - Azure Blob Storage.
// - S3 Object Storage. // - AWS S3.
// - Google Cloud Storage. // - Google Cloud Storage.
// - Add your favorite backend here. // - 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) { switch gatewayBackend(backendType) {
case azureBackend: case azureBackend:
return newAzureLayer(endpoint, accessKey, secretKey, secure) return newAzureLayer(args)
case s3Backend: case s3Backend:
return newS3Gateway(endpoint, accessKey, secretKey, secure) return newS3Gateway(args)
case gcsBackend: case gcsBackend:
return newGCSGateway(endpoint, accessKey, secretKey, secure) return newGCSGateway(args)
} }
return nil, fmt.Errorf("Unrecognized backend type %s", backendType) return nil, fmt.Errorf("Unrecognized backend type %s", backendType)
@ -371,15 +359,10 @@ func gatewayMain(ctx *cli.Context, backendType gatewayBackend) {
err := validateGatewayArguments(serverAddr, endpointAddr) err := validateGatewayArguments(serverAddr, endpointAddr)
fatalIf(err, "Invalid argument") 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. // Create certs path for SSL configuration.
fatalIf(createConfigDir(), "Unable to create configuration directory") 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") fatalIf(err, "Unable to initialize gateway layer")
initNSLock(false) // Enable local namespace lock. initNSLock(false) // Enable local namespace lock.

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

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