Add constants for commonly used values. (#3588)

This is a consolidation effort, avoiding usage
of naked strings in codebase. Whenever possible
use constants which can be repurposed elsewhere.

This also fixes `goconst ./...` reported issues.
This commit is contained in:
Harshavardhana 2017-01-18 12:24:34 -08:00 committed by GitHub
parent f803bb4b3d
commit 62f8343879
79 changed files with 461 additions and 462 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -121,7 +121,7 @@ func testServicesCmdHandler(cmd cmdType, args map[string]interface{}, t *testing
// initialize NSLock. // initialize NSLock.
initNSLock(false) initNSLock(false)
// Initialize configuration for access/secret credentials. // Initialize configuration for access/secret credentials.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize server config. %s", err) t.Fatalf("Unable to initialize server config. %s", err)
} }
@ -238,7 +238,7 @@ func TestListLocksHandler(t *testing.T) {
// initialize NSLock. // initialize NSLock.
initNSLock(false) initNSLock(false)
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize server config. %s", err) t.Fatalf("Unable to initialize server config. %s", err)
} }
@ -323,7 +323,7 @@ func TestClearLocksHandler(t *testing.T) {
// initialize NSLock. // initialize NSLock.
initNSLock(false) initNSLock(false)
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize server config. %s", err) t.Fatalf("Unable to initialize server config. %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ func testAdminCmd(cmd cmdType, t *testing.T) {
// this is to make sure that the tests are not affected by modified globals. // this is to make sure that the tests are not affected by modified globals.
resetTestGlobals() resetTestGlobals()
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Failed to create test config - %v", err) t.Fatalf("Failed to create test config - %v", err)
} }

View File

@ -675,15 +675,11 @@ func getAPIError(code APIErrorCode) APIError {
// getErrorResponse gets in standard error and resource value and // getErrorResponse gets in standard error and resource value and
// provides a encodable populated response values // provides a encodable populated response values
func getAPIErrorResponse(err APIError, resource string) APIErrorResponse { func getAPIErrorResponse(err APIError, resource string) APIErrorResponse {
var data = APIErrorResponse{} return APIErrorResponse{
data.Code = err.Code Code: err.Code,
data.Message = err.Description Message: err.Description,
if resource != "" { Resource: resource,
data.Resource = resource RequestID: "3L137",
HostID: "3L137",
} }
// TODO implement this in future
data.RequestID = "3L137"
data.HostID = "3L137"
return data
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -278,8 +278,8 @@ func generateListBucketsResponse(buckets []BucketInfo) ListBucketsResponse {
var data = ListBucketsResponse{} var data = ListBucketsResponse{}
var owner = Owner{} var owner = Owner{}
owner.ID = "minio" owner.ID = globalMinioDefaultOwnerID
owner.DisplayName = "minio" owner.DisplayName = globalMinioDefaultOwnerID
for _, bucket := range buckets { for _, bucket := range buckets {
var listbucket = Bucket{} var listbucket = Bucket{}
@ -301,8 +301,8 @@ func generateListObjectsV1Response(bucket, prefix, marker, delimiter string, max
var owner = Owner{} var owner = Owner{}
var data = ListObjectsResponse{} var data = ListObjectsResponse{}
owner.ID = "minio" owner.ID = globalMinioDefaultOwnerID
owner.DisplayName = "minio" owner.DisplayName = globalMinioDefaultOwnerID
for _, object := range resp.Objects { for _, object := range resp.Objects {
var content = Object{} var content = Object{}
@ -315,7 +315,7 @@ func generateListObjectsV1Response(bucket, prefix, marker, delimiter string, max
content.ETag = "\"" + object.MD5Sum + "\"" content.ETag = "\"" + object.MD5Sum + "\""
} }
content.Size = object.Size content.Size = object.Size
content.StorageClass = "STANDARD" content.StorageClass = globalMinioDefaultStorageClass
content.Owner = owner content.Owner = owner
// object.HealInfo is non-empty only when resp is constructed in ListObjectsHeal. // object.HealInfo is non-empty only when resp is constructed in ListObjectsHeal.
content.HealInfo = object.HealInfo content.HealInfo = object.HealInfo
@ -349,8 +349,8 @@ func generateListObjectsV2Response(bucket, prefix, token, startAfter, delimiter
var data = ListObjectsV2Response{} var data = ListObjectsV2Response{}
if fetchOwner { if fetchOwner {
owner.ID = "minio" owner.ID = globalMinioDefaultOwnerID
owner.DisplayName = "minio" owner.DisplayName = globalMinioDefaultOwnerID
} }
for _, object := range resp.Objects { for _, object := range resp.Objects {
@ -364,7 +364,7 @@ func generateListObjectsV2Response(bucket, prefix, token, startAfter, delimiter
content.ETag = "\"" + object.MD5Sum + "\"" content.ETag = "\"" + object.MD5Sum + "\""
} }
content.Size = object.Size content.Size = object.Size
content.StorageClass = "STANDARD" content.StorageClass = globalMinioDefaultStorageClass
content.Owner = owner content.Owner = owner
contents = append(contents, content) contents = append(contents, content)
} }
@ -423,11 +423,11 @@ func generateListPartsResponse(partsInfo ListPartsInfo) ListPartsResponse {
listPartsResponse.Bucket = partsInfo.Bucket listPartsResponse.Bucket = partsInfo.Bucket
listPartsResponse.Key = partsInfo.Object listPartsResponse.Key = partsInfo.Object
listPartsResponse.UploadID = partsInfo.UploadID listPartsResponse.UploadID = partsInfo.UploadID
listPartsResponse.StorageClass = "STANDARD" listPartsResponse.StorageClass = globalMinioDefaultStorageClass
listPartsResponse.Initiator.ID = "minio" listPartsResponse.Initiator.ID = globalMinioDefaultOwnerID
listPartsResponse.Initiator.DisplayName = "minio" listPartsResponse.Initiator.DisplayName = globalMinioDefaultOwnerID
listPartsResponse.Owner.ID = "minio" listPartsResponse.Owner.ID = globalMinioDefaultOwnerID
listPartsResponse.Owner.DisplayName = "minio" listPartsResponse.Owner.DisplayName = globalMinioDefaultOwnerID
listPartsResponse.MaxParts = partsInfo.MaxParts listPartsResponse.MaxParts = partsInfo.MaxParts
listPartsResponse.PartNumberMarker = partsInfo.PartNumberMarker listPartsResponse.PartNumberMarker = partsInfo.PartNumberMarker

View File

@ -58,12 +58,12 @@ func isRequestPresignedSignatureV2(r *http.Request) bool {
// Verify if request has AWS Post policy Signature Version '4'. // Verify if request has AWS Post policy Signature Version '4'.
func isRequestPostPolicySignatureV4(r *http.Request) bool { func isRequestPostPolicySignatureV4(r *http.Request) bool {
return strings.Contains(r.Header.Get("Content-Type"), "multipart/form-data") && r.Method == "POST" return strings.Contains(r.Header.Get("Content-Type"), "multipart/form-data") && r.Method == httpPOST
} }
// Verify if the request has AWS Streaming Signature Version '4'. This is only valid for 'PUT' operation. // Verify if the request has AWS Streaming Signature Version '4'. This is only valid for 'PUT' operation.
func isRequestSignStreamingV4(r *http.Request) bool { func isRequestSignStreamingV4(r *http.Request) bool {
return r.Header.Get("x-amz-content-sha256") == streamingContentSHA256 && r.Method == "PUT" return r.Header.Get("x-amz-content-sha256") == streamingContentSHA256 && r.Method == httpPUT
} }
// Authorization type. // Authorization type.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -37,7 +37,7 @@ func TestGetRequestAuthType(t *testing.T) {
req: &http.Request{ req: &http.Request{
URL: &url.URL{ URL: &url.URL{
Host: "localhost:9000", Host: "localhost:9000",
Scheme: "http", Scheme: httpScheme,
Path: "/", Path: "/",
}, },
Header: http.Header{ Header: http.Header{
@ -54,7 +54,7 @@ func TestGetRequestAuthType(t *testing.T) {
req: &http.Request{ req: &http.Request{
URL: &url.URL{ URL: &url.URL{
Host: "localhost:9000", Host: "localhost:9000",
Scheme: "http", Scheme: httpScheme,
Path: "/", Path: "/",
}, },
Header: http.Header{ Header: http.Header{
@ -69,7 +69,7 @@ func TestGetRequestAuthType(t *testing.T) {
req: &http.Request{ req: &http.Request{
URL: &url.URL{ URL: &url.URL{
Host: "localhost:9000", Host: "localhost:9000",
Scheme: "http", Scheme: httpScheme,
Path: "/", Path: "/",
}, },
Header: http.Header{ Header: http.Header{
@ -84,7 +84,7 @@ func TestGetRequestAuthType(t *testing.T) {
req: &http.Request{ req: &http.Request{
URL: &url.URL{ URL: &url.URL{
Host: "localhost:9000", Host: "localhost:9000",
Scheme: "http", Scheme: httpScheme,
Path: "/", Path: "/",
RawQuery: "X-Amz-Credential=EXAMPLEINVALIDEXAMPL%2Fs3%2F20160314%2Fus-east-1", RawQuery: "X-Amz-Credential=EXAMPLEINVALIDEXAMPL%2Fs3%2F20160314%2Fus-east-1",
}, },
@ -97,7 +97,7 @@ func TestGetRequestAuthType(t *testing.T) {
req: &http.Request{ req: &http.Request{
URL: &url.URL{ URL: &url.URL{
Host: "localhost:9000", Host: "localhost:9000",
Scheme: "http", Scheme: httpScheme,
Path: "/", Path: "/",
}, },
Header: http.Header{ Header: http.Header{
@ -309,7 +309,7 @@ func mustNewSignedRequest(method string, urlStr string, contentLength int64, bod
// Tests is requested authenticated function, tests replies for s3 errors. // Tests is requested authenticated function, tests replies for s3 errors.
func TestIsReqAuthenticated(t *testing.T) { func TestIsReqAuthenticated(t *testing.T) {
path, err := newTestConfig("us-east-1") path, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,7 +22,7 @@ import (
) )
func TestLogin(t *testing.T) { func TestLogin(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Failed to create test config - %v", err) t.Fatalf("Failed to create test config - %v", err)
} }
@ -77,7 +77,7 @@ func TestLogin(t *testing.T) {
// Invalid password length // Invalid password length
{ {
args: LoginRPCArgs{ args: LoginRPCArgs{
Username: "minio", Username: globalMinioDefaultOwnerID,
Password: "aaa", Password: "aaa",
Version: Version, Version: Version,
}, },

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -148,7 +148,7 @@ func runPutObjectPartBenchmark(b *testing.B, obj ObjectLayer, partSize int) {
// creates XL/FS backend setup, obtains the object layer and calls the runPutObjectPartBenchmark function. // creates XL/FS backend setup, obtains the object layer and calls the runPutObjectPartBenchmark function.
func benchmarkPutObjectPart(b *testing.B, instanceType string, objSize int) { func benchmarkPutObjectPart(b *testing.B, instanceType string, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -167,7 +167,7 @@ func benchmarkPutObjectPart(b *testing.B, instanceType string, objSize int) {
// creates XL/FS backend setup, obtains the object layer and calls the runPutObjectBenchmark function. // creates XL/FS backend setup, obtains the object layer and calls the runPutObjectBenchmark function.
func benchmarkPutObject(b *testing.B, instanceType string, objSize int) { func benchmarkPutObject(b *testing.B, instanceType string, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -186,7 +186,7 @@ func benchmarkPutObject(b *testing.B, instanceType string, objSize int) {
// creates XL/FS backend setup, obtains the object layer and runs parallel benchmark for put object. // creates XL/FS backend setup, obtains the object layer and runs parallel benchmark for put object.
func benchmarkPutObjectParallel(b *testing.B, instanceType string, objSize int) { func benchmarkPutObjectParallel(b *testing.B, instanceType string, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -206,7 +206,7 @@ func benchmarkPutObjectParallel(b *testing.B, instanceType string, objSize int)
// Benchmark utility functions for ObjectLayer.GetObject(). // Benchmark utility functions for ObjectLayer.GetObject().
// Creates Object layer setup ( MakeBucket, PutObject) and then runs the benchmark. // Creates Object layer setup ( MakeBucket, PutObject) and then runs the benchmark.
func runGetObjectBenchmark(b *testing.B, obj ObjectLayer, objSize int) { func runGetObjectBenchmark(b *testing.B, obj ObjectLayer, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -275,7 +275,7 @@ func generateBytesData(size int) []byte {
// creates XL/FS backend setup, obtains the object layer and calls the runGetObjectBenchmark function. // creates XL/FS backend setup, obtains the object layer and calls the runGetObjectBenchmark function.
func benchmarkGetObject(b *testing.B, instanceType string, objSize int) { func benchmarkGetObject(b *testing.B, instanceType string, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -294,7 +294,7 @@ func benchmarkGetObject(b *testing.B, instanceType string, objSize int) {
// creates XL/FS backend setup, obtains the object layer and runs parallel benchmark for ObjectLayer.GetObject() . // creates XL/FS backend setup, obtains the object layer and runs parallel benchmark for ObjectLayer.GetObject() .
func benchmarkGetObjectParallel(b *testing.B, instanceType string, objSize int) { func benchmarkGetObjectParallel(b *testing.B, instanceType string, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -314,7 +314,7 @@ func benchmarkGetObjectParallel(b *testing.B, instanceType string, objSize int)
// Parallel benchmark utility functions for ObjectLayer.PutObject(). // Parallel benchmark utility functions for ObjectLayer.PutObject().
// Creates Object layer setup ( MakeBucket ) and then runs the PutObject benchmark. // Creates Object layer setup ( MakeBucket ) and then runs the PutObject benchmark.
func runPutObjectBenchmarkParallel(b *testing.B, obj ObjectLayer, objSize int) { func runPutObjectBenchmarkParallel(b *testing.B, obj ObjectLayer, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }
@ -362,7 +362,7 @@ func runPutObjectBenchmarkParallel(b *testing.B, obj ObjectLayer, objSize int) {
// Parallel benchmark utility functions for ObjectLayer.GetObject(). // Parallel benchmark utility functions for ObjectLayer.GetObject().
// Creates Object layer setup ( MakeBucket, PutObject) and then runs the benchmark. // Creates Object layer setup ( MakeBucket, PutObject) and then runs the benchmark.
func runGetObjectBenchmarkParallel(b *testing.B, obj ObjectLayer, objSize int) { func runGetObjectBenchmarkParallel(b *testing.B, obj ObjectLayer, objSize int) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -100,7 +100,7 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
return return
} }
if s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", "us-east-1"); s3Error != ErrNone { if s3Error := checkRequestAuthType(r, bucket, "s3:GetBucketLocation", globalMinioDefaultRegion); s3Error != ErrNone {
writeErrorResponse(w, s3Error, r.URL) writeErrorResponse(w, s3Error, r.URL)
return return
} }
@ -115,7 +115,7 @@ func (api objectAPIHandlers) GetBucketLocationHandler(w http.ResponseWriter, r *
encodedSuccessResponse := encodeResponse(LocationResponse{}) encodedSuccessResponse := encodeResponse(LocationResponse{})
// Get current region. // Get current region.
region := serverConfig.GetRegion() region := serverConfig.GetRegion()
if region != "us-east-1" { if region != globalMinioDefaultRegion {
encodedSuccessResponse = encodeResponse(LocationResponse{ encodedSuccessResponse = encodeResponse(LocationResponse{
Location: region, Location: region,
}) })
@ -187,7 +187,7 @@ func (api objectAPIHandlers) ListBucketsHandler(w http.ResponseWriter, r *http.R
} }
// ListBuckets does not have any bucket action. // ListBuckets does not have any bucket action.
s3Error := checkRequestAuthType(r, "", "", "us-east-1") s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion)
if s3Error == ErrInvalidRegion { if s3Error == ErrInvalidRegion {
// Clients like boto3 send listBuckets() call signed with region that is configured. // Clients like boto3 send listBuckets() call signed with region that is configured.
s3Error = checkRequestAuthType(r, "", "", serverConfig.GetRegion()) s3Error = checkRequestAuthType(r, "", "", serverConfig.GetRegion())
@ -334,7 +334,7 @@ func (api objectAPIHandlers) PutBucketHandler(w http.ResponseWriter, r *http.Req
} }
// PutBucket does not have any bucket action. // PutBucket does not have any bucket action.
if s3Error := checkRequestAuthType(r, "", "", "us-east-1"); s3Error != ErrNone { if s3Error := checkRequestAuthType(r, "", "", globalMinioDefaultRegion); s3Error != ErrNone {
writeErrorResponse(w, s3Error, r.URL) writeErrorResponse(w, s3Error, r.URL)
return return
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ func newFlushWriter(writer io.Writer) http.ResponseWriter {
// Tests write notification code. // Tests write notification code.
func TestWriteNotification(t *testing.T) { func TestWriteNotification(t *testing.T) {
// Initialize a new test config. // Initialize a new test config.
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize test config %s", err) t.Fatalf("Unable to initialize test config %s", err)
} }
@ -112,7 +112,7 @@ func TestWriteNotification(t *testing.T) {
func TestSendBucketNotification(t *testing.T) { func TestSendBucketNotification(t *testing.T) {
// Initialize a new test config. // Initialize a new test config.
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize test config %s", err) t.Fatalf("Unable to initialize test config %s", err)
} }
@ -185,7 +185,7 @@ func testGetBucketNotificationHandler(obj ObjectLayer, instanceType, bucketName
filterRules := []filterRule{ filterRules := []filterRule{
{ {
Name: "prefix", Name: "prefix",
Value: "minio", Value: globalMinioDefaultOwnerID,
}, },
{ {
Name: "suffix", Name: "suffix",

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -218,7 +218,7 @@ func TestValidEvents(t *testing.T) {
// Tests queue arn validation. // Tests queue arn validation.
func TestQueueARN(t *testing.T) { func TestQueueARN(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }
@ -302,7 +302,7 @@ func TestQueueARN(t *testing.T) {
// Test unmarshal queue arn. // Test unmarshal queue arn.
func TestUnmarshalSQSARN(t *testing.T) { func TestUnmarshalSQSARN(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }

View File

@ -22,12 +22,15 @@ var (
// GOPATH - GOPATH value at the time of build. // GOPATH - GOPATH value at the time of build.
GOPATH = "" GOPATH = ""
// Go get development tag.
goGetTag = "DEVELOPMENT.GOGET"
// Version - version time.RFC3339. // Version - version time.RFC3339.
Version = "DEVELOPMENT.GOGET" Version = goGetTag
// ReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ. // ReleaseTag - release tag in TAG.%Y-%m-%dT%H-%M-%SZ.
ReleaseTag = "DEVELOPMENT.GOGET" ReleaseTag = goGetTag
// CommitID - latest commit id. // CommitID - latest commit id.
CommitID = "DEVELOPMENT.GOGET" CommitID = goGetTag
// ShortCommitID - first 12 characters from CommitID. // ShortCommitID - first 12 characters from CommitID.
ShortCommitID = CommitID[:12] ShortCommitID = CommitID[:12]
) )

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -47,7 +47,7 @@ func TestCheckPortAvailability(t *testing.T) {
err = checkPortAvailability(test.port) err = checkPortAvailability(test.port)
// Skip if the os is windows due to https://github.com/golang/go/issues/7598 // Skip if the os is windows due to https://github.com/golang/go/issues/7598
if err == nil && runtime.GOOS != "windows" { if err == nil && runtime.GOOS != globalWindowsOSName {
t.Fatalf("checkPortAvailability should fail for port: %s. Error: %v", test.port, err) t.Fatalf("checkPortAvailability should fail for port: %s. Error: %v", test.port, err)
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -127,7 +127,7 @@ func migrateV2ToV3() error {
srvConfig.Region = cv2.Credentials.Region srvConfig.Region = cv2.Credentials.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature V4. // Region needs to be set for AWS Signature V4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = consoleLogger{ srvConfig.Logger.Console = consoleLogger{
Enable: true, Enable: true,
@ -191,7 +191,7 @@ func migrateV3ToV4() error {
srvConfig.Region = cv3.Region srvConfig.Region = cv3.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv3.Logger.Console srvConfig.Logger.Console = cv3.Logger.Console
srvConfig.Logger.File = cv3.Logger.File srvConfig.Logger.File = cv3.Logger.File
@ -237,7 +237,7 @@ func migrateV4ToV5() error {
srvConfig.Region = cv4.Region srvConfig.Region = cv4.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv4.Logger.Console srvConfig.Logger.Console = cv4.Logger.Console
srvConfig.Logger.File = cv4.Logger.File srvConfig.Logger.File = cv4.Logger.File
@ -286,7 +286,7 @@ func migrateV5ToV6() error {
srvConfig.Region = cv5.Region srvConfig.Region = cv5.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv5.Logger.Console srvConfig.Logger.Console = cv5.Logger.Console
srvConfig.Logger.File = cv5.Logger.File srvConfig.Logger.File = cv5.Logger.File
@ -362,7 +362,7 @@ func migrateV6ToV7() error {
srvConfig.Region = cv6.Region srvConfig.Region = cv6.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv6.Logger.Console srvConfig.Logger.Console = cv6.Logger.Console
srvConfig.Logger.File = cv6.Logger.File srvConfig.Logger.File = cv6.Logger.File
@ -426,7 +426,7 @@ func migrateV7ToV8() error {
srvConfig.Region = cv7.Region srvConfig.Region = cv7.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv7.Logger.Console srvConfig.Logger.Console = cv7.Logger.Console
srvConfig.Logger.File = cv7.Logger.File srvConfig.Logger.File = cv7.Logger.File
@ -496,7 +496,7 @@ func migrateV8ToV9() error {
srvConfig.Region = cv8.Region srvConfig.Region = cv8.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv8.Logger.Console srvConfig.Logger.Console = cv8.Logger.Console
srvConfig.Logger.Console.Level = "error" srvConfig.Logger.Console.Level = "error"
@ -583,7 +583,7 @@ func migrateV9ToV10() error {
srvConfig.Region = cv9.Region srvConfig.Region = cv9.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv9.Logger.Console srvConfig.Logger.Console = cv9.Logger.Console
srvConfig.Logger.File = cv9.Logger.File srvConfig.Logger.File = cv9.Logger.File
@ -668,7 +668,7 @@ func migrateV10ToV11() error {
srvConfig.Region = cv10.Region srvConfig.Region = cv10.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv10.Logger.Console srvConfig.Logger.Console = cv10.Logger.Console
srvConfig.Logger.File = cv10.Logger.File srvConfig.Logger.File = cv10.Logger.File
@ -756,7 +756,7 @@ func migrateV11ToV12() error {
srvConfig.Region = cv11.Region srvConfig.Region = cv11.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv11.Logger.Console srvConfig.Logger.Console = cv11.Logger.Console
srvConfig.Logger.File = cv11.Logger.File srvConfig.Logger.File = cv11.Logger.File
@ -861,7 +861,7 @@ func migrateV12ToV13() error {
srvConfig.Region = cv12.Region srvConfig.Region = cv12.Region
if srvConfig.Region == "" { if srvConfig.Region == "" {
// Region needs to be set for AWS Signature Version 4. // Region needs to be set for AWS Signature Version 4.
srvConfig.Region = "us-east-1" srvConfig.Region = globalMinioDefaultRegion
} }
srvConfig.Logger.Console = cv12.Logger.Console srvConfig.Logger.Console = cv12.Logger.Console
srvConfig.Logger.File = cv12.Logger.File srvConfig.Logger.File = cv12.Logger.File

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import (
// Test if config v1 is purged // Test if config v1 is purged
func TestServerConfigMigrateV1(t *testing.T) { func TestServerConfigMigrateV1(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -58,7 +58,7 @@ func TestServerConfigMigrateV1(t *testing.T) {
// Test if all migrate code returns nil when config file does not // Test if all migrate code returns nil when config file does not
// exist // exist
func TestServerConfigMigrateInexistentConfig(t *testing.T) { func TestServerConfigMigrateInexistentConfig(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -110,7 +110,7 @@ func TestServerConfigMigrateInexistentConfig(t *testing.T) {
// Test if a config migration from v2 to v12 is successfully done // Test if a config migration from v2 to v12 is successfully done
func TestServerConfigMigrateV2toV12(t *testing.T) { func TestServerConfigMigrateV2toV12(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -169,7 +169,7 @@ func TestServerConfigMigrateV2toV12(t *testing.T) {
// Test if all migrate code returns error with corrupted config files // Test if all migrate code returns error with corrupted config files
func TestServerConfigMigrateFaultyConfig(t *testing.T) { func TestServerConfigMigrateFaultyConfig(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ func initConfig() (bool, error) {
// Initialize server config. // Initialize server config.
srvCfg := &serverConfigV13{} srvCfg := &serverConfigV13{}
srvCfg.Version = globalMinioConfigVersion srvCfg.Version = globalMinioConfigVersion
srvCfg.Region = "us-east-1" srvCfg.Region = globalMinioDefaultRegion
srvCfg.Credential = newCredential() srvCfg.Credential = newCredential()
// Enable console logger by default on a fresh run. // Enable console logger by default on a fresh run.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -22,14 +22,14 @@ import (
) )
func TestServerConfig(t *testing.T) { func TestServerConfig(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
// remove the root directory after the test ends. // remove the root directory after the test ends.
defer removeAll(rootPath) defer removeAll(rootPath)
if serverConfig.GetRegion() != "us-east-1" { if serverConfig.GetRegion() != globalMinioDefaultRegion {
t.Errorf("Expecting region `us-east-1` found %s", serverConfig.GetRegion()) t.Errorf("Expecting region `us-east-1` found %s", serverConfig.GetRegion())
} }

View File

@ -40,11 +40,11 @@ func newHashWriters(diskCount int, algo string) []hash.Hash {
// newHash - gives you a newly allocated hash depending on the input algorithm. // newHash - gives you a newly allocated hash depending on the input algorithm.
func newHash(algo string) (h hash.Hash) { func newHash(algo string) (h hash.Hash) {
switch algo { switch algo {
case "sha256": case sha256Algo:
// sha256 checksum specially on ARM64 platforms or whenever // sha256 checksum specially on ARM64 platforms or whenever
// requested as dictated by `xl.json` entry. // requested as dictated by `xl.json` entry.
h = sha256.New() h = sha256.New()
case "blake2b": case blake2bAlgo:
// ignore the error, because New512 without a key never fails // ignore the error, because New512 without a key never fails
// New512 only returns a non-nil error, if the length of the passed // New512 only returns a non-nil error, if the length of the passed
// key > 64 bytes - but we use blake2b as hash function (no key) // key > 64 bytes - but we use blake2b as hash function (no key)

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -28,7 +28,7 @@ import (
// Test InitEventNotifier with faulty disks // Test InitEventNotifier with faulty disks
func TestInitEventNotifierFaultyDisks(t *testing.T) { func TestInitEventNotifierFaultyDisks(t *testing.T) {
// Prepare for tests // Prepare for tests
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -85,7 +85,7 @@ func TestInitEventNotifierFaultyDisks(t *testing.T) {
func TestInitEventNotifierWithPostgreSQL(t *testing.T) { func TestInitEventNotifierWithPostgreSQL(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -116,7 +116,7 @@ func TestInitEventNotifierWithPostgreSQL(t *testing.T) {
func TestInitEventNotifierWithNATS(t *testing.T) { func TestInitEventNotifierWithNATS(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -147,7 +147,7 @@ func TestInitEventNotifierWithNATS(t *testing.T) {
func TestInitEventNotifierWithWebHook(t *testing.T) { func TestInitEventNotifierWithWebHook(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -178,7 +178,7 @@ func TestInitEventNotifierWithWebHook(t *testing.T) {
func TestInitEventNotifierWithAMQP(t *testing.T) { func TestInitEventNotifierWithAMQP(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -209,7 +209,7 @@ func TestInitEventNotifierWithAMQP(t *testing.T) {
func TestInitEventNotifierWithElasticSearch(t *testing.T) { func TestInitEventNotifierWithElasticSearch(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -240,7 +240,7 @@ func TestInitEventNotifierWithElasticSearch(t *testing.T) {
func TestInitEventNotifierWithRedis(t *testing.T) { func TestInitEventNotifierWithRedis(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -346,7 +346,7 @@ func TestInitEventNotifier(t *testing.T) {
filterRules := []filterRule{ filterRules := []filterRule{
{ {
Name: "prefix", Name: "prefix",
Value: "minio", Value: globalMinioDefaultOwnerID,
}, },
{ {
Name: "suffix", Name: "suffix",
@ -569,7 +569,7 @@ func TestAddRemoveBucketListenerConfig(t *testing.T) {
filterRules := []filterRule{ filterRules := []filterRule{
{ {
Name: "prefix", Name: "prefix",
Value: "minio", Value: globalMinioDefaultOwnerID,
}, },
{ {
Name: "suffix", Name: "suffix",

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -812,7 +812,7 @@ func TestLoadFormatXLErrs(t *testing.T) {
// Tests for healFormatXLCorruptedDisks() with cases which lead to errors // Tests for healFormatXLCorruptedDisks() with cases which lead to errors
func TestHealFormatXLCorruptedDisksErrs(t *testing.T) { func TestHealFormatXLCorruptedDisksErrs(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -968,7 +968,7 @@ func TestHealFormatXLCorruptedDisksErrs(t *testing.T) {
// Tests for healFormatXLFreshDisks() with cases which lead to errors // Tests for healFormatXLFreshDisks() with cases which lead to errors
func TestHealFormatXLFreshDisksErrs(t *testing.T) { func TestHealFormatXLFreshDisksErrs(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -164,11 +164,22 @@ func (m *fsMetaV1) ReadFrom(reader io.Reader) (n int64, err error) {
return int64(len(metadataBytes)), nil return int64(len(metadataBytes)), nil
} }
// FS metadata constants.
const (
// FS backend meta version.
fsMetaVersion = "1.0.0"
// FS backend meta format.
fsMetaFormat = "fs"
// Add more constants here.
)
// newFSMetaV1 - initializes new fsMetaV1. // newFSMetaV1 - initializes new fsMetaV1.
func newFSMetaV1() (fsMeta fsMetaV1) { func newFSMetaV1() (fsMeta fsMetaV1) {
fsMeta = fsMetaV1{} fsMeta = fsMetaV1{}
fsMeta.Version = "1.0.0" fsMeta.Version = fsMetaVersion
fsMeta.Format = "fs" fsMeta.Format = fsMetaFormat
fsMeta.Minio.Release = ReleaseTag fsMeta.Minio.Release = ReleaseTag
return fsMeta return fsMeta
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -51,7 +51,7 @@ func (fs fsObjects) deleteUploadsJSON(bucket, object, uploadID string) error {
uploadsMetaPath := pathJoin(uploadPath, uploadsJSONFile) uploadsMetaPath := pathJoin(uploadPath, uploadsJSONFile)
// Special case for windows please read through. // Special case for windows please read through.
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
// Ordinarily windows does not permit deletion or renaming of files still // Ordinarily windows does not permit deletion or renaming of files still
// in use, but if all open handles to that file were opened with FILE_SHARE_DELETE // in use, but if all open handles to that file were opened with FILE_SHARE_DELETE
// then it can permit renames and deletions of open files. // then it can permit renames and deletions of open files.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -48,7 +48,7 @@ func TestNewMultipartUploadFaultyDisk(t *testing.T) {
// TestPutObjectPartFaultyDisk - test PutObjectPart with faulty disks // TestPutObjectPartFaultyDisk - test PutObjectPart with faulty disks
func TestPutObjectPartFaultyDisk(t *testing.T) { func TestPutObjectPartFaultyDisk(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -69,7 +69,7 @@ func TestRWPool(t *testing.T) {
// Fails to create a file if there is a directory. // Fails to create a file if there is a directory.
_, err = rwPool.Create(pathJoin(path, "success-vol", "file")) _, err = rwPool.Create(pathJoin(path, "success-vol", "file"))
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
if err != errFileAccessDenied { if err != errFileAccessDenied {
t.Fatal("Unexpected error", err) t.Fatal("Unexpected error", err)
} }
@ -87,7 +87,7 @@ func TestRWPool(t *testing.T) {
// Fails to read a directory. // Fails to read a directory.
_, err = rwPool.Open(pathJoin(path, "success-vol", "file")) _, err = rwPool.Open(pathJoin(path, "success-vol", "file"))
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
if err != errFileAccessDenied { if err != errFileAccessDenied {
t.Fatal("Unexpected error", err) t.Fatal("Unexpected error", err)
} }
@ -99,7 +99,7 @@ func TestRWPool(t *testing.T) {
// Fails to open a file which has a parent as file. // Fails to open a file which has a parent as file.
_, err = rwPool.Open(pathJoin(path, "success-vol", "file/path/1.txt/test")) _, err = rwPool.Open(pathJoin(path, "success-vol", "file/path/1.txt/test"))
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
if err != errFileAccessDenied { if err != errFileAccessDenied {
t.Fatal("Unexpected error", err) t.Fatal("Unexpected error", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -179,7 +179,7 @@ func newFSObjectLayer(fsPath string) (ObjectLayer, error) {
func (fs fsObjects) checkDiskFree() (err error) { func (fs fsObjects) checkDiskFree() (err error) {
// We don't validate disk space or inode utilization on windows. // We don't validate disk space or inode utilization on windows.
// Each windows calls to 'GetVolumeInformationW' takes around 3-5seconds. // Each windows calls to 'GetVolumeInformationW' takes around 3-5seconds.
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return nil return nil
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,7 +49,7 @@ func TestNewFS(t *testing.T) {
// TestFSShutdown - initialize a new FS object layer then calls // TestFSShutdown - initialize a new FS object layer then calls
// Shutdown to check returned results // Shutdown to check returned results
func TestFSShutdown(t *testing.T) { func TestFSShutdown(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -139,7 +139,7 @@ func setBrowserCacheControlHandler(h http.Handler) http.Handler {
} }
func (h cacheControlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (h cacheControlHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" && guessIsBrowserReq(r) && globalIsBrowserEnabled { if r.Method == httpGET && guessIsBrowserReq(r) && globalIsBrowserEnabled {
// For all browser requests set appropriate Cache-Control policies // For all browser requests set appropriate Cache-Control policies
if strings.HasPrefix(r.URL.Path, reservedBucket+"/") { if strings.HasPrefix(r.URL.Path, reservedBucket+"/") {
if strings.HasSuffix(r.URL.Path, ".js") || r.URL.Path == reservedBucket+"/favicon.ico" { if strings.HasSuffix(r.URL.Path, ".js") || r.URL.Path == reservedBucket+"/favicon.ico" {
@ -249,11 +249,31 @@ type resourceHandler struct {
handler http.Handler handler http.Handler
} }
// List of http methods.
const (
httpGET = "GET"
httpPUT = "PUT"
httpHEAD = "HEAD"
httpPOST = "POST"
httpDELETE = "DELETE"
httpOPTIONS = "OPTIONS"
)
// List of default allowable HTTP methods.
var defaultAllowableHTTPMethods = []string{
httpGET,
httpPUT,
httpHEAD,
httpPOST,
httpDELETE,
httpOPTIONS,
}
// setCorsHandler handler for CORS (Cross Origin Resource Sharing) // setCorsHandler handler for CORS (Cross Origin Resource Sharing)
func setCorsHandler(h http.Handler) http.Handler { func setCorsHandler(h http.Handler) http.Handler {
c := cors.New(cors.Options{ c := cors.New(cors.Options{
AllowedOrigins: []string{"*"}, AllowedOrigins: []string{"*"},
AllowedMethods: []string{"GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS"}, AllowedMethods: defaultAllowableHTTPMethods,
AllowedHeaders: []string{"*"}, AllowedHeaders: []string{"*"},
ExposedHeaders: []string{"ETag"}, ExposedHeaders: []string{"ETag"},
}) })
@ -328,7 +348,7 @@ func (h resourceHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
} }
} }
// A put method on path "/" doesn't make sense, ignore it. // A put method on path "/" doesn't make sense, ignore it.
if r.Method == "PUT" && r.URL.Path == "/" { if r.Method == httpPUT && r.URL.Path == "/" {
writeErrorResponse(w, ErrNotImplemented, r.URL) writeErrorResponse(w, ErrNotImplemented, r.URL)
return return
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,6 +45,11 @@ const (
globalMinioKeyFile = "private.key" globalMinioKeyFile = "private.key"
globalMinioConfigFile = "config.json" globalMinioConfigFile = "config.json"
globalMinioCertExpireWarnDays = time.Hour * 24 * 30 // 30 days. globalMinioCertExpireWarnDays = time.Hour * 24 * 30 // 30 days.
globalMinioDefaultRegion = "us-east-1"
globalMinioDefaultOwnerID = "minio"
globalMinioDefaultStorageClass = "STANDARD"
globalWindowsOSName = "windows"
// Add new global values here. // Add new global values here.
) )
@ -118,10 +123,8 @@ var (
// global colors. // global colors.
var ( var (
colorRed = color.New(color.FgRed).SprintFunc()
colorBold = color.New(color.Bold).SprintFunc() colorBold = color.New(color.Bold).SprintFunc()
colorBlue = color.New(color.FgBlue).SprintfFunc() colorBlue = color.New(color.FgBlue).SprintfFunc()
colorGreen = color.New(color.FgGreen).SprintfFunc()
) )
// Parse command arguments and set global variables accordingly // Parse command arguments and set global variables accordingly

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -39,9 +39,9 @@ func isValidLocationConstraint(r *http.Request) (s3Error APIErrorCode) {
// Once region has been obtained we proceed to verify it. // Once region has been obtained we proceed to verify it.
incomingRegion := locationConstraint.Location incomingRegion := locationConstraint.Location
if incomingRegion == "" { if incomingRegion == "" {
// Location constraint is empty for region "us-east-1", // Location constraint is empty for region globalMinioDefaultRegion,
// in accordance with protocol. // in accordance with protocol.
incomingRegion = "us-east-1" incomingRegion = globalMinioDefaultRegion
} }
// Return errInvalidRegion if location constraint does not match // Return errInvalidRegion if location constraint does not match
// with configured region. // with configured region.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,7 +27,7 @@ import (
// Tests validate bucket LocationConstraint. // Tests validate bucket LocationConstraint.
func TestIsValidLocationContraint(t *testing.T) { func TestIsValidLocationContraint(t *testing.T) {
path, err := newTestConfig("us-east-1") path, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }
@ -63,12 +63,12 @@ func TestIsValidLocationContraint(t *testing.T) {
expectedCode APIErrorCode expectedCode APIErrorCode
}{ }{
// Test case - 1. // Test case - 1.
{"us-east-1", "us-east-1", ErrNone}, {globalMinioDefaultRegion, globalMinioDefaultRegion, ErrNone},
// Test case - 2. // Test case - 2.
// In case of empty request body ErrNone is returned. // In case of empty request body ErrNone is returned.
{"", "us-east-1", ErrNone}, {"", globalMinioDefaultRegion, ErrNone},
// Test case - 3. // Test case - 3.
{"eu-central-1", "us-east-1", ErrInvalidRegion}, {"eu-central-1", globalMinioDefaultRegion, ErrInvalidRegion},
} }
for i, testCase := range testCases { for i, testCase := range testCases {
inputRequest, e := createExpectedRequest(&http.Request{}, testCase.locationForInputRequest) inputRequest, e := createExpectedRequest(&http.Request{}, testCase.locationForInputRequest)

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -19,7 +19,7 @@ package cmd
import "testing" import "testing"
func testAuthenticate(authType string, t *testing.T) { func testAuthenticate(authType string, t *testing.T) {
testPath, err := newTestConfig("us-east-1") testPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -45,7 +45,7 @@ func testLockEquality(lriLeft, lriRight []lockRequesterInfo) bool {
// Helper function to create a lock server for testing // Helper function to create a lock server for testing
func createLockTestServer(t *testing.T) (string, *lockServer, string) { func createLockTestServer(t *testing.T) (string, *lockServer, string) {
testPath, err := newTestConfig("us-east-1") testPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }
@ -446,7 +446,7 @@ func TestLockRpcServerExpired(t *testing.T) {
// Test initialization of lock servers. // Test initialization of lock servers.
func TestLockServers(t *testing.T) { func TestLockServers(t *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return return
} }
@ -466,19 +466,19 @@ func TestLockServers(t *testing.T) {
isDistXL: true, isDistXL: true,
srvCmdConfig: serverCmdConfig{ srvCmdConfig: serverCmdConfig{
endpoints: []*url.URL{{ endpoints: []*url.URL{{
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
Path: "/mnt/disk1", Path: "/mnt/disk1",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.1.2:9000", Host: "1.1.1.2:9000",
Path: "/mnt/disk2", Path: "/mnt/disk2",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.1:9000", Host: "1.1.2.1:9000",
Path: "/mnt/disk3", Path: "/mnt/disk3",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.2:9000", Host: "1.1.2.2:9000",
Path: "/mnt/disk4", Path: "/mnt/disk4",
}}, }},
@ -490,19 +490,19 @@ func TestLockServers(t *testing.T) {
isDistXL: true, isDistXL: true,
srvCmdConfig: serverCmdConfig{ srvCmdConfig: serverCmdConfig{
endpoints: []*url.URL{{ endpoints: []*url.URL{{
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
Path: "/mnt/disk1", Path: "/mnt/disk1",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
Path: "/mnt/disk2", Path: "/mnt/disk2",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.1:9000", Host: "1.1.2.1:9000",
Path: "/mnt/disk3", Path: "/mnt/disk3",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.2:9000", Host: "1.1.2.2:9000",
Path: "/mnt/disk4", Path: "/mnt/disk4",
}}, }},

View File

@ -40,7 +40,7 @@ func (p postHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Tests web hook initialization. // Tests web hook initialization.
func TestNewWebHookNotify(t *testing.T) { func TestNewWebHookNotify(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -159,12 +159,12 @@ func getPath(ep *url.URL) string {
} }
var diskPath string var diskPath string
// For windows ep.Path is usually empty // For windows ep.Path is usually empty
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
switch ep.Scheme { switch ep.Scheme {
case "": case "":
// Eg. "minio server .\export" // Eg. "minio server .\export"
diskPath = ep.Path diskPath = ep.Path
case "http", "https": case httpScheme, httpsScheme:
// For full URLs windows drive is part of URL path. // For full URLs windows drive is part of URL path.
// Eg: http://ip:port/C:\mydrive // Eg: http://ip:port/C:\mydrive
// For windows trim off the preceding "/". // For windows trim off the preceding "/".

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -106,7 +106,7 @@ func TestGetPath(t *testing.T) {
epStr string epStr string
path string path string
} }
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
testCases = []struct { testCases = []struct {
epStr string epStr string
path string path string

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -182,7 +182,7 @@ func testGetObject(obj ObjectLayer, instanceType string, t TestErrHandler) {
// Wrapper for calling GetObject with permission denied expected // Wrapper for calling GetObject with permission denied expected
func TestGetObjectPermissionDenied(t *testing.T) { func TestGetObjectPermissionDenied(t *testing.T) {
// Windows doesn't support Chmod under golang // Windows doesn't support Chmod under golang
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
ExecObjectLayerDiskAlteredTest(t, testGetObjectPermissionDenied) ExecObjectLayerDiskAlteredTest(t, testGetObjectPermissionDenied)
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015-2016 Minio, Inc. * Minio Cloud Storage, (C) 2015-2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -588,7 +588,7 @@ func BenchmarkListObjects(b *testing.B) {
} }
defer removeAll(directory) defer removeAll(directory)
// initialize the root directory. // initialize the root directory.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
b.Fatalf("Unable to initialize config. %s", err) b.Fatalf("Unable to initialize config. %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -1061,7 +1061,7 @@ func testListMultipartUploads(obj ObjectLayer, instanceType string, t TestErrHan
{ {
MaxUploads: 10, MaxUploads: 10,
IsTruncated: false, IsTruncated: false,
Prefix: "minio", Prefix: globalMinioDefaultOwnerID,
UploadIDMarker: uploadIDs[4], UploadIDMarker: uploadIDs[4],
Uploads: []uploadMetadata{ Uploads: []uploadMetadata{
{ {
@ -1201,7 +1201,7 @@ func testListMultipartUploads(obj ObjectLayer, instanceType string, t TestErrHan
// Test case with `prefix` and `KeyMarker` (Test number 48). // Test case with `prefix` and `KeyMarker` (Test number 48).
{bucketNames[2], "minio-object", objectNames[1], "", "", 10, listMultipartResults[34], nil, true}, {bucketNames[2], "minio-object", objectNames[1], "", "", 10, listMultipartResults[34], nil, true},
// Test case with `prefix` and `uploadIDMarker` (Test number 49). // Test case with `prefix` and `uploadIDMarker` (Test number 49).
// {bucketNames[2], "minio", "", uploadIDs[4], "", 10, listMultipartResults[35], nil, true}, // {bucketNames[2], globalMinioDefaultOwnerID, "", uploadIDs[4], "", 10, listMultipartResults[35], nil, true},
// Test case with `KeyMarker` and `uploadIDMarker` (Test number 50). // Test case with `KeyMarker` and `uploadIDMarker` (Test number 50).
// {bucketNames[2], "minio-object.txt", "", uploadIDs[5], "", 10, listMultipartResults[36], nil, true}, // {bucketNames[2], "minio-object.txt", "", uploadIDs[5], "", 10, listMultipartResults[36], nil, true},
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -79,7 +79,7 @@ func isSysErrTooLong(err error) bool {
// and ERROR_DIR_NOT_EMPTY for windows (directory not empty). // and ERROR_DIR_NOT_EMPTY for windows (directory not empty).
func isSysErrNotEmpty(err error) bool { func isSysErrNotEmpty(err error) bool {
if pathErr, ok := err.(*os.PathError); ok { if pathErr, ok := err.(*os.PathError); ok {
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
if errno, _ok := pathErr.Err.(syscall.Errno); _ok && errno == 0x91 { if errno, _ok := pathErr.Err.(syscall.Errno); _ok && errno == 0x91 {
// ERROR_DIR_NOT_EMPTY // ERROR_DIR_NOT_EMPTY
return true return true
@ -95,7 +95,7 @@ func isSysErrNotEmpty(err error) bool {
// Check if the given error corresponds to the specific ERROR_PATH_NOT_FOUND for windows // Check if the given error corresponds to the specific ERROR_PATH_NOT_FOUND for windows
func isSysErrPathNotFound(err error) bool { func isSysErrPathNotFound(err error) bool {
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
return false return false
} }
if pathErr, ok := err.(*os.PathError); ok { if pathErr, ok := err.(*os.PathError); ok {
@ -109,7 +109,7 @@ func isSysErrPathNotFound(err error) bool {
// Check if the given error corresponds to the specific ERROR_INVALID_HANDLE for windows // Check if the given error corresponds to the specific ERROR_INVALID_HANDLE for windows
func isSysErrHandleInvalid(err error) bool { func isSysErrHandleInvalid(err error) bool {
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
return false return false
} }
// Check if err contains ERROR_INVALID_HANDLE errno // Check if err contains ERROR_INVALID_HANDLE errno

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -34,7 +34,7 @@ func TestSysErrors(t *testing.T) {
if !ok { if !ok {
t.Fatalf("Unexpected error expecting %s", syscall.ENOTDIR) t.Fatalf("Unexpected error expecting %s", syscall.ENOTDIR)
} }
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
pathErr = &os.PathError{Err: syscall.ENOTEMPTY} pathErr = &os.PathError{Err: syscall.ENOTEMPTY}
ok = isSysErrNotEmpty(pathErr) ok = isSysErrNotEmpty(pathErr)
if !ok { if !ok {
@ -47,7 +47,7 @@ func TestSysErrors(t *testing.T) {
t.Fatal("Unexpected error expecting 0x91") t.Fatal("Unexpected error expecting 0x91")
} }
} }
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
pathErr = &os.PathError{Err: syscall.Errno(0x03)} pathErr = &os.PathError{Err: syscall.Errno(0x03)}
ok = isSysErrPathNotFound(pathErr) ok = isSysErrPathNotFound(pathErr)
if !ok { if !ok {

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -24,7 +24,7 @@ import (
// preparePath rewrites path to handle any OS specific details. // preparePath rewrites path to handle any OS specific details.
func preparePath(path string) string { func preparePath(path string) string {
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
// Microsoft Windows supports long path names using // Microsoft Windows supports long path names using
// uniform naming convention (UNC). // uniform naming convention (UNC).
return UNCPath(path) return UNCPath(path)

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -157,7 +157,7 @@ func getDiskInfo(diskPath string) (di disk.Info, err error) {
func (s *posix) checkDiskFree() (err error) { func (s *posix) checkDiskFree() (err error) {
// We don't validate disk space or inode utilization on windows. // We don't validate disk space or inode utilization on windows.
// Each windows calls to 'GetVolumeInformationW' takes around 3-5seconds. // Each windows calls to 'GetVolumeInformationW' takes around 3-5seconds.
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return nil return nil
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -286,7 +286,7 @@ func TestPosixMakeVol(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posix, err := newPosix("/usr") posix, err := newPosix("/usr")
if err != nil { if err != nil {
@ -377,7 +377,7 @@ func TestPosixDeleteVol(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posixStorage, err = newPosix("/usr") posixStorage, err = newPosix("/usr")
if err != nil { if err != nil {
@ -656,7 +656,7 @@ func TestPosixPosixListDir(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posixStorage, err = newPosix("/usr") posixStorage, err = newPosix("/usr")
if err != nil { if err != nil {
@ -770,7 +770,7 @@ func TestPosixDeleteFile(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posixStorage, err = newPosix("/usr") posixStorage, err = newPosix("/usr")
if err != nil { if err != nil {
@ -881,7 +881,7 @@ func TestPosixReadFile(t *testing.T) {
-1, 5, -1, 5,
nil, nil,
func() error { func() error {
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return &os.PathError{ return &os.PathError{
Op: "seek", Op: "seek",
Path: preparePath(slashpath.Join(path, "success-vol", "myobject")), Path: preparePath(slashpath.Join(path, "success-vol", "myobject")),
@ -937,7 +937,7 @@ func TestPosixReadFile(t *testing.T) {
if err != nil && testCase.expectedErr != nil { if err != nil && testCase.expectedErr != nil {
// Validate if the type string of the errors are an exact match. // Validate if the type string of the errors are an exact match.
if err.Error() != testCase.expectedErr.Error() { if err.Error() != testCase.expectedErr.Error() {
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
t.Errorf("Case: %d %#v, expected: %s, got: %s", i+1, testCase, testCase.expectedErr, err) t.Errorf("Case: %d %#v, expected: %s, got: %s", i+1, testCase, testCase.expectedErr, err)
} else { } else {
var resultErrno, expectErrno uintptr var resultErrno, expectErrno uintptr
@ -1075,7 +1075,7 @@ func TestPosixAppendFile(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posixStorage, err = newPosix("/usr") posixStorage, err = newPosix("/usr")
if err != nil { if err != nil {
@ -1162,7 +1162,7 @@ func TestPosixPrepareFile(t *testing.T) {
} }
// TestPosix for permission denied. // TestPosix for permission denied.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
// Initialize posix storage layer for permission denied error. // Initialize posix storage layer for permission denied error.
posixStorage, err = newPosix("/usr") posixStorage, err = newPosix("/usr")
if err != nil { if err != nil {

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -115,7 +115,7 @@ func TestPostPolicyBucketHandler(t *testing.T) {
// testPostPolicyBucketHandler - Tests validate post policy handler uploading objects. // testPostPolicyBucketHandler - Tests validate post policy handler uploading objects.
func testPostPolicyBucketHandler(obj ObjectLayer, instanceType string, t TestErrHandler) { func testPostPolicyBucketHandler(obj ObjectLayer, instanceType string, t TestErrHandler) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Initializing config.json failed") t.Fatalf("Initializing config.json failed")
} }
@ -402,7 +402,7 @@ func TestPostPolicyBucketHandlerRedirect(t *testing.T) {
// testPostPolicyBucketHandlerRedirect tests POST Object when success_action_redirect is specified // testPostPolicyBucketHandlerRedirect tests POST Object when success_action_redirect is specified
func testPostPolicyBucketHandlerRedirect(obj ObjectLayer, instanceType string, t TestErrHandler) { func testPostPolicyBucketHandlerRedirect(obj ObjectLayer, instanceType string, t TestErrHandler) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Initializing config.json failed") t.Fatalf("Initializing config.json failed")
} }

View File

@ -27,6 +27,31 @@ import (
"time" "time"
) )
// startWithConds - map which indicates if a given condition supports starts-with policy operator
var startsWithConds = map[string]bool{
"$acl": true,
"$bucket": false,
"$cache-control": true,
"$content-type": true,
"$content-disposition": true,
"$content-encoding": true,
"$expires": true,
"$key": true,
"$success_action_redirect": true,
"$redirect": true,
"$success_action_status": false,
"$x-amz-algorithm": false,
"$x-amz-credential": false,
"$x-amz-date": false,
}
// Add policy conditionals.
const (
policyCondEqual = "eq"
policyCondStartsWith = "starts-with"
policyCondContentLength = "content-length-range"
)
// toString - Safely convert interface to string without causing panic. // toString - Safely convert interface to string without causing panic.
func toString(val interface{}) string { func toString(val interface{}) string {
switch v := val.(type) { switch v := val.(type) {
@ -127,7 +152,7 @@ func parsePostPolicyForm(policy string) (PostPolicyForm, error) {
Operator string Operator string
Value string Value string
}{ }{
Operator: "eq", Operator: policyCondEqual,
Value: toString(v), Value: toString(v),
} }
} }
@ -136,7 +161,7 @@ func parsePostPolicyForm(policy string) (PostPolicyForm, error) {
return parsedPolicy, fmt.Errorf("Malformed conditional fields %s of type %s found in POST policy form", condt, reflect.TypeOf(condt).String()) return parsedPolicy, fmt.Errorf("Malformed conditional fields %s of type %s found in POST policy form", condt, reflect.TypeOf(condt).String())
} }
switch toLowerString(condt[0]) { switch toLowerString(condt[0]) {
case "eq", "starts-with": case policyCondEqual, policyCondStartsWith:
for _, v := range condt { // Pre-check all values for type. for _, v := range condt { // Pre-check all values for type.
if !isString(v) { if !isString(v) {
// All values must be of type string. // All values must be of type string.
@ -151,7 +176,7 @@ func parsePostPolicyForm(policy string) (PostPolicyForm, error) {
Operator: operator, Operator: operator,
Value: value, Value: value,
} }
case "content-length-range": case policyCondContentLength:
min, err := toInteger(condt[1]) min, err := toInteger(condt[1])
if err != nil { if err != nil {
return parsedPolicy, err return parsedPolicy, err
@ -180,31 +205,13 @@ func parsePostPolicyForm(policy string) (PostPolicyForm, error) {
return parsedPolicy, nil return parsedPolicy, nil
} }
// startWithConds - map which indicates if a given condition supports starts-with policy operator
var startsWithConds = map[string]bool{
"$acl": true,
"$bucket": false,
"$cache-control": true,
"$content-type": true,
"$content-disposition": true,
"$content-encoding": true,
"$expires": true,
"$key": true,
"$success_action_redirect": true,
"$redirect": true,
"$success_action_status": false,
"$x-amz-algorithm": false,
"$x-amz-credential": false,
"$x-amz-date": false,
}
// checkPolicyCond returns a boolean to indicate if a condition is satisified according // checkPolicyCond returns a boolean to indicate if a condition is satisified according
// to the passed operator // to the passed operator
func checkPolicyCond(op string, input1, input2 string) bool { func checkPolicyCond(op string, input1, input2 string) bool {
switch op { switch op {
case "eq": case policyCondEqual:
return input1 == input2 return input1 == input2
case "starts-with": case policyCondStartsWith:
return strings.HasPrefix(input1, input2) return strings.HasPrefix(input1, input2)
} }
return false return false
@ -231,7 +238,7 @@ func checkPostPolicy(formValues map[string]string, postPolicyForm PostPolicyForm
// If the current policy condition is known // If the current policy condition is known
if startsWithSupported, condFound := startsWithConds[cond]; condFound { if startsWithSupported, condFound := startsWithConds[cond]; condFound {
// Check if the current condition supports starts-with operator // Check if the current condition supports starts-with operator
if op == "starts-with" && !startsWithSupported { if op == policyCondStartsWith && !startsWithSupported {
return ErrAccessDenied return ErrAccessDenied
} }
// Check if current policy condition is satisfied // Check if current policy condition is satisfied

View File

@ -65,9 +65,9 @@ func printHealMsg(endpoints []*url.URL, storageDisks []StorageAPI, fn printOnceF
// for single node XL, distributed XL and when minio server is bound // for single node XL, distributed XL and when minio server is bound
// to a specific ip:port. // to a specific ip:port.
func getHealEndpoint(tls bool, firstEndpoint *url.URL) (cEndpoint *url.URL) { func getHealEndpoint(tls bool, firstEndpoint *url.URL) (cEndpoint *url.URL) {
scheme := "http" scheme := httpScheme
if tls { if tls {
scheme = "https" scheme = httpsScheme
} }
cEndpoint = &url.URL{ cEndpoint = &url.URL{
Scheme: scheme, Scheme: scheme,
@ -93,6 +93,12 @@ func getHealEndpoint(tls bool, firstEndpoint *url.URL) (cEndpoint *url.URL) {
return cEndpoint return cEndpoint
} }
// Disks offline and online strings..
const (
diskOffline = "offline"
diskOnline = "online"
)
// Constructs a formatted heal message, when cluster is found to be in state where it requires healing. // Constructs a formatted heal message, when cluster is found to be in state where it requires healing.
// healing is optional, server continues to initialize object layer after printing this message. // healing is optional, server continues to initialize object layer after printing this message.
// it is upto the end user to perform a heal if needed. // it is upto the end user to perform a heal if needed.
@ -112,9 +118,9 @@ func getHealMsg(endpoints []*url.URL, storageDisks []StorageAPI) string {
humanize.IBytes(uint64(info.Total)), humanize.IBytes(uint64(info.Total)),
func() string { func() string {
if info.Total > 0 { if info.Total > 0 {
return "online" return diskOnline
} }
return "offline" return diskOffline
}(), }(),
) )
} }
@ -142,9 +148,9 @@ func getStorageInitMsg(titleMsg string, endpoints []*url.URL, storageDisks []Sto
humanize.IBytes(uint64(info.Total)), humanize.IBytes(uint64(info.Total)),
func() string { func() string {
if info.Total > 0 { if info.Total > 0 {
return "online" return diskOnline
} }
return "offline" return diskOffline
}(), }(),
) )
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -27,11 +27,11 @@ func TestGetHealEndpoint(t *testing.T) {
// Test for a SSL scheme. // Test for a SSL scheme.
tls := true tls := true
hURL := getHealEndpoint(tls, &url.URL{ hURL := getHealEndpoint(tls, &url.URL{
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
}) })
sHURL := &url.URL{ sHURL := &url.URL{
Scheme: "https", Scheme: httpsScheme,
Host: "localhost:9000", Host: "localhost:9000",
} }
if !reflect.DeepEqual(hURL, sHURL) { if !reflect.DeepEqual(hURL, sHURL) {
@ -41,11 +41,11 @@ func TestGetHealEndpoint(t *testing.T) {
// Test a non-TLS scheme. // Test a non-TLS scheme.
tls = false tls = false
hURL = getHealEndpoint(tls, &url.URL{ hURL = getHealEndpoint(tls, &url.URL{
Scheme: "https", Scheme: httpsScheme,
Host: "localhost:9000", Host: "localhost:9000",
}) })
sHURL = &url.URL{ sHURL = &url.URL{
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
} }
if !reflect.DeepEqual(hURL, sHURL) { if !reflect.DeepEqual(hURL, sHURL) {
@ -61,7 +61,7 @@ func TestGetHealEndpoint(t *testing.T) {
Path: "/export", Path: "/export",
}) })
sHURL = &url.URL{ sHURL = &url.URL{
Scheme: "http", Scheme: httpScheme,
Host: "", Host: "",
} }
globalMinioAddr = "" globalMinioAddr = ""
@ -73,7 +73,7 @@ func TestGetHealEndpoint(t *testing.T) {
// Tests heal message to be correct and properly formatted. // Tests heal message to be correct and properly formatted.
func TestHealMsg(t *testing.T) { func TestHealMsg(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Unable to initialize test config", err) t.Fatal("Unable to initialize test config", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import (
// Tests retry storage. // Tests retry storage.
func TestRetryStorage(t *testing.T) { func TestRetryStorage(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -26,7 +26,7 @@ import (
// endpoints. // endpoints.
func TestMakeS3Peers(t *testing.T) { func TestMakeS3Peers(t *testing.T) {
// Initialize configuration // Initialize configuration
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }

View File

@ -1,92 +0,0 @@
/*
* Minio Cloud Storage (C) 2016 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package cmd
import (
"fmt"
"runtime"
"strings"
"github.com/cheggaaa/pb"
"github.com/dustin/go-humanize"
"github.com/minio/mc/pkg/console"
)
// fixateScanBar truncates or stretches text to fit within the terminal size.
func fixateScanBar(text string, width int) string {
if len([]rune(text)) > width {
// Trim text to fit within the screen
trimSize := len([]rune(text)) - width + 3 //"..."
if trimSize < len([]rune(text)) {
text = "..." + text[trimSize:]
}
} else {
text += strings.Repeat(" ", width-len([]rune(text)))
}
return text
}
// Progress bar function report objects being scaned.
type scanBarFunc func(string)
// scanBarFactory returns a progress bar function to report URL scanning.
func scanBarFactory() scanBarFunc {
fileCount := 0
termWidth, err := pb.GetTerminalWidth()
if err != nil {
termWidth = 80
}
// Cursor animate channel.
cursorCh := cursorAnimate()
return func(source string) {
scanPrefix := fmt.Sprintf("[%s] %s ", humanize.Comma(int64(fileCount)), string(<-cursorCh))
source = fixateScanBar(source, termWidth-len([]rune(scanPrefix)))
barText := scanPrefix + source
console.PrintC("\r" + barText + "\r")
fileCount++
}
}
// cursorAnimate - returns a animated rune through read channel for every read.
func cursorAnimate() <-chan rune {
cursorCh := make(chan rune)
var cursors string
switch runtime.GOOS {
case "linux":
// cursors = "➩➪➫➬➭➮➯➱"
// cursors = "▁▃▄▅▆▇█▇▆▅▄▃"
cursors = "◐◓◑◒"
// cursors = "←↖↑↗→↘↓↙"
// cursors = "◴◷◶◵"
// cursors = "◰◳◲◱"
//cursors = "⣾⣽⣻⢿⡿⣟⣯⣷"
case "darwin":
cursors = "◐◓◑◒"
default:
cursors = "|/-\\"
}
go func() {
for {
for _, cursor := range cursors {
cursorCh <- cursor
}
}
}()
return cursorCh
}

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -195,36 +195,45 @@ func isDistributedSetup(eps []*url.URL) bool {
return false return false
} }
// Returns true if path is empty, or equals to '.', '/', '\' characters.
func isPathSentinel(path string) bool {
return path == "" || path == "." || path == "/" || path == `\`
}
// Returned when path is empty or root path.
var errEmptyRootPath = errors.New("Empty or root path is not allowed")
// Invalid scheme passed.
var errInvalidScheme = errors.New("Invalid scheme")
// Check if endpoint is in expected syntax by valid scheme/path across all platforms. // Check if endpoint is in expected syntax by valid scheme/path across all platforms.
func checkEndpointURL(endpointURL *url.URL) (err error) { func checkEndpointURL(endpointURL *url.URL) (err error) {
// applicable to all OS. // Applicable to all OS.
if endpointURL.Scheme == "" || endpointURL.Scheme == "http" || endpointURL.Scheme == "https" { if endpointURL.Scheme == "" || endpointURL.Scheme == httpScheme || endpointURL.Scheme == httpsScheme {
urlPath := path.Clean(endpointURL.Path) if isPathSentinel(path.Clean(endpointURL.Path)) {
if urlPath == "" || urlPath == "." || urlPath == "/" || urlPath == `\` { err = errEmptyRootPath
err = fmt.Errorf("Empty or root path is not allowed")
} }
return err return err
} }
// Applicable to Windows only. // Applicable to Windows only.
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
// On Windows, endpoint can be a path with drive eg. C:\Export and its URL.Scheme is 'C'. // On Windows, endpoint can be a path with drive eg. C:\Export and its URL.Scheme is 'C'.
// Check if URL.Scheme is a single letter alphabet to represent a drive. // Check if URL.Scheme is a single letter alphabet to represent a drive.
// Note: URL.Parse() converts scheme into lower case always. // Note: URL.Parse() converts scheme into lower case always.
if len(endpointURL.Scheme) == 1 && endpointURL.Scheme[0] >= 'a' && endpointURL.Scheme[0] <= 'z' { if len(endpointURL.Scheme) == 1 && endpointURL.Scheme[0] >= 'a' && endpointURL.Scheme[0] <= 'z' {
// If endpoint is C:\ or C:\export, URL.Path does not have path information like \ or \export // If endpoint is C:\ or C:\export, URL.Path does not have path information like \ or \export
// hence we directly work with endpoint. // hence we directly work with endpoint.
urlPath := strings.SplitN(path.Clean(endpointURL.String()), ":", 2)[1] if isPathSentinel(strings.SplitN(path.Clean(endpointURL.String()), ":", 2)[1]) {
if urlPath == "" || urlPath == "." || urlPath == "/" || urlPath == `\` { err = errEmptyRootPath
err = fmt.Errorf("Empty or root path is not allowed")
} }
return err return err
} }
} }
return fmt.Errorf("Invalid scheme") return errInvalidScheme
} }
// Check if endpoints are in expected syntax by valid scheme/path across all platforms. // Check if endpoints are in expected syntax by valid scheme/path across all platforms.
@ -300,7 +309,7 @@ func checkServerSyntax(c *cli.Context) {
} }
for _, ep := range endpoints { for _, ep := range endpoints {
if ep.Scheme == "https" && !globalIsSSL { if ep.Scheme == httpsScheme && !globalIsSSL {
// Certificates should be provided for https configuration. // Certificates should be provided for https configuration.
fatalIf(errInvalidArgument, "Certificates not provided for secure configuration") fatalIf(errInvalidArgument, "Certificates not provided for secure configuration")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -133,7 +133,7 @@ func TestFinalizeAPIEndpoints(t *testing.T) {
// Tests all the expected input disks for function checkSufficientDisks. // Tests all the expected input disks for function checkSufficientDisks.
func TestCheckSufficientDisks(t *testing.T) { func TestCheckSufficientDisks(t *testing.T) {
var xlDisks []string var xlDisks []string
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
xlDisks = []string{ xlDisks = []string{
"C:\\mnt\\backend1", "C:\\mnt\\backend1",
"C:\\mnt\\backend2", "C:\\mnt\\backend2",
@ -330,7 +330,7 @@ func TestCheckEndpointsSyntax(t *testing.T) {
"server:/export", "server:/export",
} }
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
successCases = append(successCases, successCases = append(successCases,
`\export`, `\export`,
`D:\export`, `D:\export`,
@ -401,7 +401,7 @@ func TestIsDistributedSetup(t *testing.T) {
disks []string disks []string
result bool result bool
} }
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
testCases = []struct { testCases = []struct {
disks []string disks []string
result bool result bool
@ -457,7 +457,7 @@ func TestIsDistributedSetup(t *testing.T) {
func TestInitServerConfig(t *testing.T) { func TestInitServerConfig(t *testing.T) {
ctx := &cli.Context{} ctx := &cli.Context{}
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Failed to set up test config") t.Fatal("Failed to set up test config")
} }

View File

@ -71,6 +71,12 @@ func NewConnMux(c net.Conn) *ConnMux {
} }
} }
const (
protocolTLS = "tls"
protocolHTTP1 = "http"
protocolHTTP2 = "http2"
)
// PeekProtocol - reads the first bytes, then checks if it is similar // PeekProtocol - reads the first bytes, then checks if it is similar
// to one of the default http methods // to one of the default http methods
func (c *ConnMux) PeekProtocol() string { func (c *ConnMux) PeekProtocol() string {
@ -79,19 +85,19 @@ func (c *ConnMux) PeekProtocol() string {
if err != io.EOF { if err != io.EOF {
errorIf(err, "Unable to peek into the protocol") errorIf(err, "Unable to peek into the protocol")
} }
return "http" return protocolHTTP1
} }
for _, m := range defaultHTTP1Methods { for _, m := range defaultHTTP1Methods {
if strings.HasPrefix(string(buf), m) { if strings.HasPrefix(string(buf), m) {
return "http" return protocolHTTP1
} }
} }
for _, m := range defaultHTTP2Methods { for _, m := range defaultHTTP2Methods {
if strings.HasPrefix(string(buf), m) { if strings.HasPrefix(string(buf), m) {
return "http2" return protocolHTTP2
} }
} }
return "tls" return protocolTLS
} }
// Read - streams the ConnMux buffer when reset flag is activated, otherwise // Read - streams the ConnMux buffer when reset flag is activated, otherwise
@ -194,10 +200,14 @@ func newListenerMux(listener net.Listener, config *tls.Config) *ListenerMux {
// and decide if we need to wrap the connection itself with a TLS or not // and decide if we need to wrap the connection itself with a TLS or not
go func(conn net.Conn) { go func(conn net.Conn) {
connMux := NewConnMux(conn) connMux := NewConnMux(conn)
if connMux.PeekProtocol() == "tls" { if connMux.PeekProtocol() == protocolTLS {
l.acceptResCh <- ListenerMuxAcceptRes{conn: tls.Server(connMux, l.config)} l.acceptResCh <- ListenerMuxAcceptRes{
conn: tls.Server(connMux, l.config),
}
} else { } else {
l.acceptResCh <- ListenerMuxAcceptRes{conn: connMux} l.acceptResCh <- ListenerMuxAcceptRes{
conn: connMux,
}
} }
}(conn) }(conn)
} }
@ -367,7 +377,7 @@ func (m *ServerMux) ListenAndServe(certFile, keyFile string) (err error) {
if tlsEnabled && r.TLS == nil { if tlsEnabled && r.TLS == nil {
// TLS is enabled but Request is not TLS configured // TLS is enabled but Request is not TLS configured
u := url.URL{ u := url.URL{
Scheme: "https", Scheme: httpsScheme,
Opaque: r.URL.Opaque, Opaque: r.URL.Opaque,
User: r.URL.User, User: r.URL.User,
Host: r.Host, Host: r.Host,

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -153,7 +153,7 @@ func TestInitListeners(t *testing.T) {
} }
} }
// Windows doesn't have 'localhost' hostname. // Windows doesn't have 'localhost' hostname.
if runtime.GOOS != "windows" { if runtime.GOOS != globalWindowsOSName {
listeners, err := initListeners("localhost:"+getFreePort(), &tls.Config{}) listeners, err := initListeners("localhost:"+getFreePort(), &tls.Config{})
if err != nil { if err != nil {
t.Fatalf("Test 3: Unable to initialize listeners %s", err) t.Fatalf("Test 3: Unable to initialize listeners %s", err)
@ -395,7 +395,7 @@ func TestListenAndServeTLS(t *testing.T) {
res, _ := client.Get("http://" + addr) res, _ := client.Get("http://" + addr)
// Without TLS we expect a re-direction from http to https // Without TLS we expect a re-direction from http to https
// And also the request is not rejected. // And also the request is not rejected.
if res != nil && res.StatusCode == http.StatusOK && res.Request.URL.Scheme == "https" { if res != nil && res.StatusCode == http.StatusOK && res.Request.URL.Scheme == httpsScheme {
okNoTLS = true okNoTLS = true
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016, 2017 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -118,7 +118,7 @@ func printCLIAccessMsg(endPoint string) {
// Configure 'mc', following block prints platform specific information for minio client. // Configure 'mc', following block prints platform specific information for minio client.
console.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide) console.Println(colorBlue("\nCommand-line Access: ") + mcQuickStartGuide)
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
mcMessage := fmt.Sprintf("$ mc.exe config host add myminio %s %s %s", endPoint, cred.AccessKey, cred.SecretKey) mcMessage := fmt.Sprintf("$ mc.exe config host add myminio %s %s %s", endPoint, cred.AccessKey, cred.SecretKey)
console.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage)) console.Println(fmt.Sprintf(getFormatStr(len(mcMessage), 3), mcMessage))
} else { } else {

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -97,7 +97,7 @@ func TestCertificateNotExpired(t *testing.T) {
// Test printing server common message. // Test printing server common message.
func TestPrintServerCommonMessage(t *testing.T) { func TestPrintServerCommonMessage(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -109,7 +109,7 @@ func TestPrintServerCommonMessage(t *testing.T) {
// Tests print cli access message. // Tests print cli access message.
func TestPrintCLIAccessMsg(t *testing.T) { func TestPrintCLIAccessMsg(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -121,7 +121,7 @@ func TestPrintCLIAccessMsg(t *testing.T) {
// Test print startup message. // Test print startup message.
func TestPrintStartupMessage(t *testing.T) { func TestPrintStartupMessage(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -51,9 +51,9 @@ func getListenIPs(serverAddr string) (hosts []string, port string, err error) {
// Finalizes the API endpoints based on the host list and port. // Finalizes the API endpoints based on the host list and port.
func finalizeAPIEndpoints(apiServer *http.Server) (endPoints []string, err error) { func finalizeAPIEndpoints(apiServer *http.Server) (endPoints []string, err error) {
// Verify current scheme. // Verify current scheme.
scheme := "http" scheme := httpScheme
if globalIsSSL { if globalIsSSL {
scheme = "https" scheme = httpsScheme
} }
// Get list of listen ips and port. // Get list of listen ips and port.

View File

@ -24,7 +24,7 @@ func TestResourceListSorting(t *testing.T) {
// Tests presigned v2 signature. // Tests presigned v2 signature.
func TestDoesPresignedV2SignatureMatch(t *testing.T) { func TestDoesPresignedV2SignatureMatch(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Unable to initialize test config.") t.Fatal("Unable to initialize test config.")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -81,7 +81,7 @@ func validateCredentialfields(t *testing.T, testNum int, expectedCredentials cre
// A valid format of creadential should be of the following format. // A valid format of creadential should be of the following format.
// Credential = accessKey + "/"+ scope // Credential = accessKey + "/"+ scope
// where scope = string.Join([]string{ currTime.Format(yyyymmdd), // where scope = string.Join([]string{ currTime.Format(yyyymmdd),
// "us-east-1", // globalMinioDefaultRegion,
// "s3", // "s3",
// "aws4_request", // "aws4_request",
// },"/") // },"/")

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,12 +49,12 @@ func skipContentSha256Cksum(r *http.Request) bool {
// isValidRegion - verify if incoming region value is valid with configured Region. // isValidRegion - verify if incoming region value is valid with configured Region.
func isValidRegion(reqRegion string, confRegion string) bool { func isValidRegion(reqRegion string, confRegion string) bool {
if confRegion == "" || confRegion == "US" { if confRegion == "" || confRegion == "US" {
confRegion = "us-east-1" confRegion = globalMinioDefaultRegion
} }
// Some older s3 clients set region as "US" instead of // Some older s3 clients set region as "US" instead of
// "us-east-1", handle it. // globalMinioDefaultRegion, handle it.
if reqRegion == "US" { if reqRegion == "US" {
reqRegion = "us-east-1" reqRegion = globalMinioDefaultRegion
} }
return reqRegion == confRegion return reqRegion == confRegion
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -82,8 +82,8 @@ func TestIsValidRegion(t *testing.T) {
}{ }{
{"", "", false}, {"", "", false},
{"us-east-1", "", true}, {globalMinioDefaultRegion, "", true},
{"us-east-1", "US", true}, {globalMinioDefaultRegion, "US", true},
{"us-west-1", "US", false}, {"us-west-1", "US", false},
{"us-west-1", "us-west-1", true}, {"us-west-1", "us-west-1", true},
// "US" was old naming convention for 'us-east-1'. // "US" was old naming convention for 'us-east-1'.

View File

@ -42,6 +42,7 @@ const (
signV4Algorithm = "AWS4-HMAC-SHA256" signV4Algorithm = "AWS4-HMAC-SHA256"
iso8601Format = "20060102T150405Z" iso8601Format = "20060102T150405Z"
yyyymmdd = "20060102" yyyymmdd = "20060102"
presignedHostHeader = "host"
) )
// getCanonicalHeaders generate a list of request headers with their values // getCanonicalHeaders generate a list of request headers with their values
@ -52,7 +53,7 @@ func getCanonicalHeaders(signedHeaders http.Header, host string) string {
headers = append(headers, strings.ToLower(k)) headers = append(headers, strings.ToLower(k))
vals[strings.ToLower(k)] = vv vals[strings.ToLower(k)] = vv
} }
headers = append(headers, "host") headers = append(headers, presignedHostHeader)
sort.Strings(headers) sort.Strings(headers)
var buf bytes.Buffer var buf bytes.Buffer
@ -60,7 +61,7 @@ func getCanonicalHeaders(signedHeaders http.Header, host string) string {
buf.WriteString(k) buf.WriteString(k)
buf.WriteByte(':') buf.WriteByte(':')
switch { switch {
case k == "host": case k == presignedHostHeader:
buf.WriteString(host) buf.WriteString(host)
fallthrough fallthrough
default: default:
@ -82,7 +83,7 @@ func getSignedHeaders(signedHeaders http.Header) string {
for k := range signedHeaders { for k := range signedHeaders {
headers = append(headers, strings.ToLower(k)) headers = append(headers, strings.ToLower(k))
} }
headers = append(headers, "host") headers = append(headers, presignedHostHeader)
sort.Strings(headers) sort.Strings(headers)
return strings.Join(headers, ";") return strings.Join(headers, ";")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -50,7 +50,7 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
// (1) It should fail if the access key is incorrect. // (1) It should fail if the access key is incorrect.
{ {
form: map[string]string{ form: map[string]string{
"X-Amz-Credential": fmt.Sprintf(credentialTemplate, "EXAMPLEINVALIDEXAMPL", now.Format(yyyymmdd), "us-east-1"), "X-Amz-Credential": fmt.Sprintf(credentialTemplate, "EXAMPLEINVALIDEXAMPL", now.Format(yyyymmdd), globalMinioDefaultRegion),
}, },
expected: ErrInvalidAccessKeyID, expected: ErrInvalidAccessKeyID,
}, },
@ -64,14 +64,14 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
// (3) It should fail if the date is invalid (or missing, in this case). // (3) It should fail if the date is invalid (or missing, in this case).
{ {
form: map[string]string{ form: map[string]string{
"X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), "us-east-1"), "X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), globalMinioDefaultRegion),
}, },
expected: ErrMalformedDate, expected: ErrMalformedDate,
}, },
// (4) It should fail with a bad signature. // (4) It should fail with a bad signature.
{ {
form: map[string]string{ form: map[string]string{
"X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), "us-east-1"), "X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), globalMinioDefaultRegion),
"X-Amz-Date": now.Format(iso8601Format), "X-Amz-Date": now.Format(iso8601Format),
"X-Amz-Signature": "invalidsignature", "X-Amz-Signature": "invalidsignature",
"Policy": "policy", "Policy": "policy",
@ -81,9 +81,9 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
// (5) It should succeed if everything is correct. // (5) It should succeed if everything is correct.
{ {
form: map[string]string{ form: map[string]string{
"X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), "us-east-1"), "X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKey, now.Format(yyyymmdd), globalMinioDefaultRegion),
"X-Amz-Date": now.Format(iso8601Format), "X-Amz-Date": now.Format(iso8601Format),
"X-Amz-Signature": getSignature(getSigningKey(serverConfig.GetCredential().SecretKey, now, "us-east-1"), "policy"), "X-Amz-Signature": getSignature(getSigningKey(serverConfig.GetCredential().SecretKey, now, globalMinioDefaultRegion), "policy"),
"Policy": "policy", "Policy": "policy",
}, },
expected: ErrNone, expected: ErrNone,
@ -100,7 +100,7 @@ func TestDoesPolicySignatureMatch(t *testing.T) {
} }
func TestDoesPresignedSignatureMatch(t *testing.T) { func TestDoesPresignedSignatureMatch(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -121,7 +121,7 @@ func TestDoesPresignedSignatureMatch(t *testing.T) {
}{ }{
// (0) Should error without a set URL query. // (0) Should error without a set URL query.
{ {
region: "us-east-1", region: globalMinioDefaultRegion,
expected: ErrInvalidQueryParams, expected: ErrInvalidQueryParams,
}, },
// (1) Should error on an invalid access key. // (1) Should error on an invalid access key.
@ -162,7 +162,7 @@ func TestDoesPresignedSignatureMatch(t *testing.T) {
"X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKeyID, now.Format(yyyymmdd), "us-west-1"), "X-Amz-Credential": fmt.Sprintf(credentialTemplate, accessKeyID, now.Format(yyyymmdd), "us-west-1"),
"X-Amz-Content-Sha256": payloadSHA256, "X-Amz-Content-Sha256": payloadSHA256,
}, },
region: "us-east-1", region: globalMinioDefaultRegion,
expected: ErrInvalidRegion, expected: ErrInvalidRegion,
}, },
// (4) Should NOT fail with an invalid region if it doesn't verify it. // (4) Should NOT fail with an invalid region if it doesn't verify it.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -188,7 +188,7 @@ func TestRPCStorageClient(t *testing.T) {
func (s *TestRPCStorageSuite) testRPCStorageClient(t *testing.T) { func (s *TestRPCStorageSuite) testRPCStorageClient(t *testing.T) {
// TODO - Fix below tests to run on windows. // TODO - Fix below tests to run on windows.
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return return
} }
s.testRPCStorageDisksInfo(t) s.testRPCStorageDisksInfo(t)

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -35,7 +35,7 @@ type testStorageRPCServer struct {
} }
func createTestStorageServer(t *testing.T) *testStorageRPCServer { func createTestStorageServer(t *testing.T) *testStorageRPCServer {
testPath, err := newTestConfig("us-east-1") testPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("unable initialize config file, %s", err) t.Fatalf("unable initialize config file, %s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -110,7 +110,7 @@ func prepareXL() (ObjectLayer, []string, error) {
// Initialize FS objects. // Initialize FS objects.
func initFSObjects(disk string, t *testing.T) (obj ObjectLayer) { func initFSObjects(disk string, t *testing.T) (obj ObjectLayer) {
newTestConfig("us-east-1") newTestConfig(globalMinioDefaultRegion)
var err error var err error
obj, err = newFSObjectLayer(disk) obj, err = newFSObjectLayer(disk)
if err != nil { if err != nil {
@ -203,7 +203,7 @@ func UnstartedTestServer(t TestErrHandler, instanceType string) TestServer {
t.Fatal("Failed to create disks for the backend") t.Fatal("Failed to create disks for the backend")
} }
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
@ -367,7 +367,7 @@ func StartTestStorageRPCServer(t TestErrHandler, instanceType string, diskN int)
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
@ -402,7 +402,7 @@ func StartTestPeersRPCServer(t TestErrHandler, instanceType string) TestServer {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
@ -691,7 +691,7 @@ func signStreamingRequest(req *http.Request, accessKey, secretKey string, currTi
// Get scope. // Get scope.
scope := strings.Join([]string{ scope := strings.Join([]string{
currTime.Format(yyyymmdd), currTime.Format(yyyymmdd),
"us-east-1", globalMinioDefaultRegion,
"s3", "s3",
"aws4_request", "aws4_request",
}, "/") }, "/")
@ -701,7 +701,7 @@ func signStreamingRequest(req *http.Request, accessKey, secretKey string, currTi
stringToSign = stringToSign + getSHA256Hash([]byte(canonicalRequest)) stringToSign = stringToSign + getSHA256Hash([]byte(canonicalRequest))
date := sumHMAC([]byte("AWS4"+secretKey), []byte(currTime.Format(yyyymmdd))) date := sumHMAC([]byte("AWS4"+secretKey), []byte(currTime.Format(yyyymmdd)))
region := sumHMAC(date, []byte("us-east-1")) region := sumHMAC(date, []byte(globalMinioDefaultRegion))
service := sumHMAC(region, []byte("s3")) service := sumHMAC(region, []byte("s3"))
signingKey := sumHMAC(service, []byte("aws4_request")) signingKey := sumHMAC(service, []byte("aws4_request"))
@ -1919,7 +1919,7 @@ func ExecObjectLayerAPITest(t *testing.T, objAPITest objAPITestType, endpoints [
initNSLock(false) initNSLock(false)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Unable to initialize server config. %s", err) t.Fatalf("Unable to initialize server config. %s", err)
} }
@ -1964,7 +1964,7 @@ type objTestDiskNotFoundType func(obj ObjectLayer, instanceType string, dirs []s
func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) { func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Unexpected error", err) t.Fatal("Unexpected error", err)
} }
@ -1989,7 +1989,7 @@ func ExecObjectLayerTest(t TestErrHandler, objTest objTestType) {
// ExecObjectLayerDiskAlteredTest - executes object layer tests while altering // ExecObjectLayerDiskAlteredTest - executes object layer tests while altering
// disks in between tests. Creates XL ObjectLayer instance and runs test for XL layer. // disks in between tests. Creates XL ObjectLayer instance and runs test for XL layer.
func ExecObjectLayerDiskAlteredTest(t *testing.T, objTest objTestDiskNotFoundType) { func ExecObjectLayerDiskAlteredTest(t *testing.T, objTest objTestDiskNotFoundType) {
configPath, err := newTestConfig("us-east-1") configPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Failed to create config directory", err) t.Fatal("Failed to create config directory", err)
} }
@ -2010,7 +2010,7 @@ type objTestStaleFilesType func(obj ObjectLayer, instanceType string, dirs []str
// ExecObjectLayerStaleFilesTest - executes object layer tests those leaves stale // ExecObjectLayerStaleFilesTest - executes object layer tests those leaves stale
// files/directories under .minio/tmp. Creates XL ObjectLayer instance and runs test for XL layer. // files/directories under .minio/tmp. Creates XL ObjectLayer instance and runs test for XL layer.
func ExecObjectLayerStaleFilesTest(t *testing.T, objTest objTestStaleFilesType) { func ExecObjectLayerStaleFilesTest(t *testing.T, objTest objTestStaleFilesType) {
configPath, err := newTestConfig("us-east-1") configPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Failed to create config directory", err) t.Fatal("Failed to create config directory", err)
} }
@ -2169,7 +2169,7 @@ func initTestBrowserPeerRPCEndPoint() http.Handler {
} }
func StartTestBrowserPeerRPCServer(t TestErrHandler, instanceType string) TestServer { func StartTestBrowserPeerRPCServer(t TestErrHandler, instanceType string) TestServer {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }
@ -2190,7 +2190,7 @@ func StartTestBrowserPeerRPCServer(t TestErrHandler, instanceType string) TestSe
} }
func StartTestS3PeerRPCServer(t TestErrHandler) (TestServer, []string) { func StartTestS3PeerRPCServer(t TestErrHandler) (TestServer, []string) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -55,7 +55,7 @@ func TestPrefixMatch(t *testing.T) {
trie = newTrie() trie = newTrie()
// Feed it some fodder: only 'minio' and 'miny-os' should trip the matcher. // Feed it some fodder: only 'minio' and 'miny-os' should trip the matcher.
trie.Insert("minio") trie.Insert(globalMinioDefaultOwnerID)
trie.Insert("amazon") trie.Insert("amazon")
trie.Insert("cheerio") trie.Insert("cheerio")
trie.Insert("miny-o's") trie.Insert("miny-o's")
@ -65,7 +65,7 @@ func TestPrefixMatch(t *testing.T) {
t.Errorf("expected two matches, got: %d", len(matches)) t.Errorf("expected two matches, got: %d", len(matches))
} }
if matches[0] != "minio" && matches[1] != "minio" { if matches[0] != globalMinioDefaultOwnerID && matches[1] != globalMinioDefaultOwnerID {
t.Errorf("expected one match to be 'minio', got: '%s' and '%s'", matches[0], matches[1]) t.Errorf("expected one match to be 'minio', got: '%s' and '%s'", matches[0], matches[1])
} }
} }

View File

@ -84,7 +84,7 @@ func parseReleaseData(data string) (time.Time, error) {
if len(releaseDateSplits) < 3 { if len(releaseDateSplits) < 3 {
return time.Time{}, (errors.New("Update data malformed")) return time.Time{}, (errors.New("Update data malformed"))
} }
if releaseDateSplits[0] != "minio" { if releaseDateSplits[0] != globalMinioDefaultOwnerID {
return time.Time{}, (errors.New("Update data malformed, missing minio tag")) return time.Time{}, (errors.New("Update data malformed, missing minio tag"))
} }
// "OFFICIAL" tag is still kept for backward compatibility. // "OFFICIAL" tag is still kept for backward compatibility.
@ -126,14 +126,14 @@ func isDocker() bool {
// Check if the minio server binary was built with source. // Check if the minio server binary was built with source.
func isSourceBuild() bool { func isSourceBuild() bool {
return Version == "DEVELOPMENT.GOGET" return Version == goGetTag
} }
// Fetch the current version of the Minio server binary. // Fetch the current version of the Minio server binary.
func getCurrentMinioVersion() (current time.Time, err error) { func getCurrentMinioVersion() (current time.Time, err error) {
// For development builds we check for binary modTime // For development builds we check for binary modTime
// to validate against latest minio server release. // to validate against latest minio server release.
if Version != "DEVELOPMENT.GOGET" { if Version != goGetTag {
// Parse current minio version into RFC3339. // Parse current minio version into RFC3339.
current, err = time.Parse(time.RFC3339, Version) current, err = time.Parse(time.RFC3339, Version)
if err != nil { if err != nil {
@ -164,7 +164,7 @@ func getReleaseUpdate(updateURL string, duration time.Duration) (updateMsg updat
downloadURL = "docker pull minio/minio" downloadURL = "docker pull minio/minio"
} else { } else {
switch runtime.GOOS { switch runtime.GOOS {
case "windows": case globalWindowsOSName:
// For windows. // For windows.
downloadURL = newUpdateURLPrefix + "/minio.exe" downloadURL = newUpdateURLPrefix + "/minio.exe"
default: default:

View File

@ -66,7 +66,7 @@ func colorizeUpdateMessage(updateString string, newerThan time.Duration) string
default: default:
// on windows terminal turn off unicode characters. // on windows terminal turn off unicode characters.
var top, bottom, sideBar string var top, bottom, sideBar string
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
top = yellow("*" + strings.Repeat("*", maxContentWidth) + "*") top = yellow("*" + strings.Repeat("*", maxContentWidth) + "*")
bottom = yellow("*" + strings.Repeat("*", maxContentWidth) + "*") bottom = yellow("*" + strings.Repeat("*", maxContentWidth) + "*")
sideBar = yellow("|") sideBar = yellow("|")

View File

@ -38,17 +38,17 @@ func TestSortByHostPath(t *testing.T) {
}, },
expected: []*url.URL{ expected: []*url.URL{
{ {
Scheme: "http", Scheme: httpScheme,
Host: "abcd.com:9000", Host: "abcd.com:9000",
Path: "/a/b/c", Path: "/a/b/c",
}, },
{ {
Scheme: "http", Scheme: httpScheme,
Host: "abcd.com:9000", Host: "abcd.com:9000",
Path: "/a/b/d", Path: "/a/b/d",
}, },
{ {
Scheme: "http", Scheme: httpScheme,
Host: "abcd.com:9000", Host: "abcd.com:9000",
Path: "/a/b/e", Path: "/a/b/e",
}, },
@ -62,17 +62,17 @@ func TestSortByHostPath(t *testing.T) {
}, },
expected: []*url.URL{ expected: []*url.URL{
{ {
Scheme: "http", Scheme: httpScheme,
Host: "abcd.com:9000", Host: "abcd.com:9000",
Path: "/a/b/c", Path: "/a/b/c",
}, },
{ {
Scheme: "http", Scheme: httpScheme,
Host: "defg.com:9000", Host: "defg.com:9000",
Path: "/a/b/c", Path: "/a/b/c",
}, },
{ {
Scheme: "http", Scheme: httpScheme,
Host: "hijk.com:9000", Host: "hijk.com:9000",
Path: "/a/b/c", Path: "/a/b/c",
}, },

View File

@ -102,9 +102,15 @@ func urlPath2BucketObjectName(u *url.URL) (bucketName, objectName string) {
return bucketName, objectName return bucketName, objectName
} }
// URI scheme constants.
const (
httpScheme = "http"
httpsScheme = "https"
)
var portMap = map[string]string{ var portMap = map[string]string{
"http": "80", httpScheme: "80",
"https": "443", httpsScheme: "443",
} }
// Given a string of the form "host", "host:port", or "[ipv6::address]:port", // Given a string of the form "host", "host:port", or "[ipv6::address]:port",

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -275,7 +275,7 @@ func TestStartProfiler(t *testing.T) {
// Tests fetch local address. // Tests fetch local address.
func TestLocalAddress(t *testing.T) { func TestLocalAddress(t *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == globalWindowsOSName {
return return
} }
@ -297,19 +297,19 @@ func TestLocalAddress(t *testing.T) {
isDistXL: true, isDistXL: true,
srvCmdConfig: serverCmdConfig{ srvCmdConfig: serverCmdConfig{
endpoints: []*url.URL{{ endpoints: []*url.URL{{
Scheme: "http", Scheme: httpScheme,
Host: "localhost:9000", Host: "localhost:9000",
Path: "/mnt/disk1", Path: "/mnt/disk1",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.1.2:9000", Host: "1.1.1.2:9000",
Path: "/mnt/disk2", Path: "/mnt/disk2",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.1:9000", Host: "1.1.2.1:9000",
Path: "/mnt/disk3", Path: "/mnt/disk3",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.2:9000", Host: "1.1.2.2:9000",
Path: "/mnt/disk4", Path: "/mnt/disk4",
}}, }},
@ -338,19 +338,19 @@ func TestLocalAddress(t *testing.T) {
isDistXL: true, isDistXL: true,
srvCmdConfig: serverCmdConfig{ srvCmdConfig: serverCmdConfig{
endpoints: []*url.URL{{ endpoints: []*url.URL{{
Scheme: "http", Scheme: httpScheme,
Host: "1.1.1.1:9000", Host: "1.1.1.1:9000",
Path: "/mnt/disk2", Path: "/mnt/disk2",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.1.2:9000", Host: "1.1.1.2:9000",
Path: "/mnt/disk2", Path: "/mnt/disk2",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.1:9000", Host: "1.1.2.1:9000",
Path: "/mnt/disk3", Path: "/mnt/disk3",
}, { }, {
Scheme: "http", Scheme: httpScheme,
Host: "1.1.2.2:9000", Host: "1.1.2.2:9000",
Path: "/mnt/disk4", Path: "/mnt/disk4",
}}, }},

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -130,7 +130,7 @@ func testLoginWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler)
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -179,7 +179,7 @@ func testStorageInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHa
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -225,7 +225,7 @@ func testServerInfoWebHandler(obj ObjectLayer, instanceType string, t TestErrHan
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -271,7 +271,7 @@ func testMakeBucketWebHandler(obj ObjectLayer, instanceType string, t TestErrHan
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -331,7 +331,7 @@ func testListBucketsWebHandler(obj ObjectLayer, instanceType string, t TestErrHa
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -388,7 +388,7 @@ func testListObjectsWebHandler(obj ObjectLayer, instanceType string, t TestErrHa
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -492,7 +492,7 @@ func testRemoveObjectWebHandler(obj ObjectLayer, instanceType string, t TestErrH
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -568,7 +568,7 @@ func testGenerateAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrH
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -614,7 +614,7 @@ func testSetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandle
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -675,7 +675,7 @@ func testGetAuthWebHandler(obj ObjectLayer, instanceType string, t TestErrHandle
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -720,7 +720,7 @@ func testUploadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandler
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -811,7 +811,7 @@ func testDownloadWebHandler(obj ObjectLayer, instanceType string, t TestErrHandl
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -903,7 +903,7 @@ func testWebPresignedGetHandler(obj ObjectLayer, instanceType string, t TestErrH
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -1016,7 +1016,7 @@ func testWebGetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestE
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -1099,7 +1099,7 @@ func testWebListAllBucketPoliciesHandler(obj ObjectLayer, instanceType string, t
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -1205,7 +1205,7 @@ func testWebSetBucketPolicyHandler(obj ObjectLayer, instanceType string, t TestE
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }
@ -1283,7 +1283,7 @@ func TestWebCheckAuthorization(t *testing.T) {
apiRouter := initTestWebRPCEndPoint(obj) apiRouter := initTestWebRPCEndPoint(obj)
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Init Test config failed", err) t.Fatal("Init Test config failed", err)
} }
@ -1365,7 +1365,7 @@ func TestWebObjectLayerNotReady(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Init Test config failed", err) t.Fatal("Init Test config failed", err)
} }
@ -1444,7 +1444,7 @@ func TestWebObjectLayerNotReady(t *testing.T) {
// TestWebObjectLayerFaultyDisks - Test Web RPC responses with faulty disks // TestWebObjectLayerFaultyDisks - Test Web RPC responses with faulty disks
func TestWebObjectLayerFaultyDisks(t *testing.T) { func TestWebObjectLayerFaultyDisks(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -1469,7 +1469,7 @@ func TestWebObjectLayerFaultyDisks(t *testing.T) {
// initialize the server and obtain the credentials and root. // initialize the server and obtain the credentials and root.
// credentials are necessary to sign the HTTP request. // credentials are necessary to sign the HTTP request.
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal("Init Test config failed", err) t.Fatal("Init Test config failed", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import (
// Tests healing of format XL. // Tests healing of format XL.
func TestHealFormatXL(t *testing.T) { func TestHealFormatXL(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -271,7 +271,7 @@ func TestHealFormatXL(t *testing.T) {
// Tests undoes and validates if the undoing completes successfully. // Tests undoes and validates if the undoing completes successfully.
func TestUndoMakeBucket(t *testing.T) { func TestUndoMakeBucket(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
@ -316,7 +316,7 @@ func TestUndoMakeBucket(t *testing.T) {
// Tests quick healing of bucket and bucket metadata. // Tests quick healing of bucket and bucket metadata.
func TestQuickHeal(t *testing.T) { func TestQuickHeal(t *testing.T) {
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage (C) 2016 Minio, Inc. * Minio Cloud Storage (C) 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,7 +25,7 @@ import (
// TestListObjectsHeal - Tests ListObjectsHeal API for XL // TestListObjectsHeal - Tests ListObjectsHeal API for XL
func TestListObjectsHeal(t *testing.T) { func TestListObjectsHeal(t *testing.T) {
rootPath, err := newTestConfig("us-east-1") rootPath, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("Init Test config failed") t.Fatalf("Init Test config failed")
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2016 Minio, Inc. * Minio Cloud Storage, (C) 2016, 2017, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,6 +54,14 @@ type checkSumInfo struct {
Hash string `json:"hash"` Hash string `json:"hash"`
} }
// Various algorithms supported by bit-rot protection feature.
const (
// "sha256" is specifically used on arm64 bit platforms.
sha256Algo = "sha256"
// Rest of the platforms default to blake2b.
blake2bAlgo = "blake2b"
)
// Constant indicates current bit-rot algo used when creating objects. // Constant indicates current bit-rot algo used when creating objects.
// Depending on the architecture we are choosing a different checksum. // Depending on the architecture we are choosing a different checksum.
var bitRotAlgo = getDefaultBitRotAlgo() var bitRotAlgo = getDefaultBitRotAlgo()
@ -71,10 +79,10 @@ func getDefaultBitRotAlgo() string {
// This would also allows erasure coded writes // This would also allows erasure coded writes
// on ARM64 servers to be on-par with their // on ARM64 servers to be on-par with their
// counter-part X86_64 servers. // counter-part X86_64 servers.
return "sha256" return sha256Algo
default: default:
// Default for all other architectures we use blake2b. // Default for all other architectures we use blake2b.
return "blake2b" return blake2bAlgo
} }
} }
@ -135,11 +143,22 @@ type xlMetaV1 struct {
Parts []objectPartInfo `json:"parts,omitempty"` Parts []objectPartInfo `json:"parts,omitempty"`
} }
// XL metadata constants.
const (
// XL meta version.
xlMetaVersion = "1.0.0"
// XL meta format string.
xlMetaFormat = "xl"
// Add new constants here.
)
// newXLMetaV1 - initializes new xlMetaV1, adds version, allocates a fresh erasure info. // newXLMetaV1 - initializes new xlMetaV1, adds version, allocates a fresh erasure info.
func newXLMetaV1(object string, dataBlocks, parityBlocks int) (xlMeta xlMetaV1) { func newXLMetaV1(object string, dataBlocks, parityBlocks int) (xlMeta xlMetaV1) {
xlMeta = xlMetaV1{} xlMeta = xlMetaV1{}
xlMeta.Version = "1.0.0" xlMeta.Version = xlMetaVersion
xlMeta.Format = "xl" xlMeta.Format = xlMetaFormat
xlMeta.Minio.Release = ReleaseTag xlMeta.Minio.Release = ReleaseTag
xlMeta.Erasure = erasureInfo{ xlMeta.Erasure = erasureInfo{
Algorithm: erasureAlgorithmKlauspost, Algorithm: erasureAlgorithmKlauspost,
@ -154,7 +173,7 @@ func newXLMetaV1(object string, dataBlocks, parityBlocks int) (xlMeta xlMetaV1)
// IsValid - tells if the format is sane by validating the version // IsValid - tells if the format is sane by validating the version
// string and format style. // string and format style.
func (m xlMetaV1) IsValid() bool { func (m xlMetaV1) IsValid() bool {
return m.Version == "1.0.0" && m.Format == "xl" return m.Version == xlMetaVersion && m.Format == xlMetaFormat
} }
// objectPartIndex - returns the index of matching object part number. // objectPartIndex - returns the index of matching object part number.

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2014-2016 Minio, Inc. * Minio Cloud Storage, (C) 2014-2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,7 +23,7 @@ import (
func TestUpdateUploadJSON(t *testing.T) { func TestUpdateUploadJSON(t *testing.T) {
// Initialize configuration // Initialize configuration
root, err := newTestConfig("us-east-1") root, err := newTestConfig(globalMinioDefaultRegion)
if err != nil { if err != nil {
t.Fatalf("%s", err) t.Fatalf("%s", err)
} }

View File

@ -1,5 +1,5 @@
/* /*
* Minio Cloud Storage, (C) 2015, 2016 Minio, Inc. * Minio Cloud Storage, (C) 2015, 2016, 2017 Minio, Inc.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -131,9 +131,9 @@ func TestHashOrder(t *testing.T) {
// newTestXLMetaV1 - initializes new xlMetaV1, adds version, allocates a fresh erasure info and metadata. // newTestXLMetaV1 - initializes new xlMetaV1, adds version, allocates a fresh erasure info and metadata.
func newTestXLMetaV1() xlMetaV1 { func newTestXLMetaV1() xlMetaV1 {
xlMeta := xlMetaV1{} xlMeta := xlMetaV1{}
xlMeta.Version = "1.0.0" xlMeta.Version = xlMetaVersion
xlMeta.Format = "xl" xlMeta.Format = xlMetaFormat
xlMeta.Minio.Release = "1.0.0" xlMeta.Minio.Release = "test"
xlMeta.Erasure = erasureInfo{ xlMeta.Erasure = erasureInfo{
Algorithm: "klauspost/reedsolomon/vandermonde", Algorithm: "klauspost/reedsolomon/vandermonde",
DataBlocks: 5, DataBlocks: 5,