diff --git a/Godeps/Godeps.json b/Godeps/Godeps.json index a6506ce0..7125f23c 100644 --- a/Godeps/Godeps.json +++ b/Godeps/Godeps.json @@ -15,7 +15,7 @@ }, { "ImportPath": "github.com/fatih/structs", - "Rev": "c06d8730d42f16f3e8dddc236c7d69c0952a8a2c" + "Rev": "c00d27128bb88e9c1adab1a53cda9c72c6d1ff9b" }, { "ImportPath": "github.com/minio/check", @@ -28,7 +28,7 @@ }, { "ImportPath": "github.com/minio/minio-go", - "Rev": "745daad6222582eb6ecbb864f0cbcdc4427dd52f" + "Rev": "dee5d16f0c4515ddb2785a1b8317ec11796d8fc3" }, { "ImportPath": "github.com/minio/minio/pkg/iodine", diff --git a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go b/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go index 80dbfa78..9d0d2ed1 100644 --- a/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go +++ b/Godeps/_workspace/src/github.com/dustin/go-humanize/comma.go @@ -33,7 +33,7 @@ func Comma(v int64) string { j-- } parts[j] = strconv.Itoa(int(v)) - return sign + strings.Join(parts[j:], ",") + return sign + strings.Join(parts[j:len(parts)], ",") } // Commaf produces a string form of the given number in base 10 with @@ -97,5 +97,5 @@ func BigComma(b *big.Int) string { j-- } parts[j] = strconv.Itoa(int(b.Int64())) - return sign + strings.Join(parts[j:], ",") + return sign + strings.Join(parts[j:len(parts)], ",") } diff --git a/Godeps/_workspace/src/github.com/fatih/structs/README.md b/Godeps/_workspace/src/github.com/fatih/structs/README.md index 1dc34048..87fccf24 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/README.md +++ b/Godeps/_workspace/src/github.com/fatih/structs/README.md @@ -43,10 +43,6 @@ m := structs.Map(server) // => ["gopher", 123456, true] v := structs.Values(server) -// Convert the names of a struct to a []string -// (see "Names methods" for more info about fields) -n := structs.Names(server) - // Convert the values of a struct to a []*Field // (see "Field methods" for more info about fields) f := structs.Fields(server) @@ -77,7 +73,6 @@ s := structs.New(server) m := s.Map() // Get a map[string]interface{} v := s.Values() // Get a []interface{} f := s.Fields() // Get a []*Field -n := s.Names() // Get a []string f := s.Field(name) // Get a *Field based on the given field name f, ok := s.FieldsOk(name) // Get a *Field based on the given field name n := s.Name() // Get the struct name diff --git a/Godeps/_workspace/src/github.com/fatih/structs/structs.go b/Godeps/_workspace/src/github.com/fatih/structs/structs.go index 1c1f68bb..47bf3545 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/structs.go +++ b/Godeps/_workspace/src/github.com/fatih/structs/structs.go @@ -171,25 +171,6 @@ func (s *Struct) Fields() []*Field { return getFields(s.value, s.TagName) } -// Names returns a slice of field names. A struct tag with the content of "-" -// ignores the checking of that particular field. Example: -// -// // Field is ignored by this package. -// Field bool `structs:"-"` -// -// It panics if s's kind is not struct. -func (s *Struct) Names() []string { - fields := getFields(s.value, s.TagName) - - names := make([]string, len(fields)) - - for i, field := range fields { - names[i] = field.Name() - } - - return names -} - func getFields(v reflect.Value, tagName string) []*Field { if v.Kind() == reflect.Ptr { v = v.Elem() @@ -406,12 +387,6 @@ func Fields(s interface{}) []*Field { return New(s).Fields() } -// Names returns a slice of field names. For more info refer to Struct types -// Names() method. It panics if s's kind is not struct. -func Names(s interface{}) []string { - return New(s).Names() -} - // IsZero returns true if all fields is equal to a zero value. For more info // refer to Struct types IsZero() method. It panics if s's kind is not struct. func IsZero(s interface{}) bool { diff --git a/Godeps/_workspace/src/github.com/fatih/structs/structs_test.go b/Godeps/_workspace/src/github.com/fatih/structs/structs_test.go index 83261760..02788b10 100644 --- a/Godeps/_workspace/src/github.com/fatih/structs/structs_test.go +++ b/Godeps/_workspace/src/github.com/fatih/structs/structs_test.go @@ -442,39 +442,6 @@ func TestValues_Anonymous(t *testing.T) { } } -func TestNames(t *testing.T) { - var T = struct { - A string - B int - C bool - }{ - A: "a-value", - B: 2, - C: true, - } - - s := Names(T) - - if len(s) != 3 { - t.Errorf("Names should return a slice of len 3, got: %d", len(s)) - } - - inSlice := func(val string) bool { - for _, v := range s { - if reflect.DeepEqual(v, val) { - return true - } - } - return false - } - - for _, val := range []string{"A", "B", "C"} { - if !inSlice(val) { - t.Errorf("Names should have the value %v", val) - } - } -} - func TestFields(t *testing.T) { var T = struct { A string diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/api_test.go b/Godeps/_workspace/src/github.com/minio/minio-go/api_test.go index 92117050..83187253 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/api_test.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/api_test.go @@ -89,7 +89,7 @@ func TestBucketOperations(t *testing.T) { if err == nil { t.Errorf("Error") } - if err.Error() != "403 Forbidden" { + if err.Error() != "Access Denied" { t.Errorf("Error") } @@ -133,7 +133,7 @@ func TestBucketOperations(t *testing.T) { if err == nil { t.Fatalf("Error") } - if err.Error() != "404 Not Found" { + if err.Error() != "The specified bucket does not exist." { t.Errorf("Error") } } @@ -191,7 +191,7 @@ func TestObjectOperations(t *testing.T) { if err == nil { t.Fatalf("Error") } - if err.Error() != "404 Not Found" { + if err.Error() != "The specified key does not exist." { t.Errorf("Error") } } diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelapi.go b/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelapi.go index 6bcb9f31..97533124 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelapi.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelapi.go @@ -335,7 +335,24 @@ func (a lowLevelAPI) headBucket(bucket string) error { if resp != nil { if resp.StatusCode != http.StatusOK { // Head has no response body, handle it - return fmt.Errorf("%s", resp.Status) + var errorResponse ErrorResponse + switch { + case resp.StatusCode == http.StatusNotFound: + errorResponse = ErrorResponse{ + Code: "NoSuchBucket", + Message: "The specified bucket does not exist.", + Resource: "/" + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + } + case resp.StatusCode == http.StatusForbidden: + errorResponse = ErrorResponse{ + Code: "AccessDenied", + Message: "Access Denied", + Resource: "/" + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + } + } + return errorResponse } } return nil @@ -367,8 +384,24 @@ func (a lowLevelAPI) deleteBucket(bucket string) error { defer resp.Body.Close() if resp != nil { if resp.StatusCode != http.StatusOK { - // Head has no response body, handle it - return fmt.Errorf("%s", resp.Status) + var errorResponse ErrorResponse + switch { + case resp.StatusCode == http.StatusNotFound: + errorResponse = ErrorResponse{ + Code: "NoSuchBucket", + Message: "The specified bucket does not exist.", + Resource: "/" + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + } + case resp.StatusCode == http.StatusForbidden: + errorResponse = ErrorResponse{ + Code: "AccessDenied", + Message: "Access Denied", + Resource: "/" + bucket, + RequestID: resp.Header.Get("x-amz-request-id"), + } + } + return errorResponse } } return nil @@ -512,7 +545,24 @@ func (a lowLevelAPI) deleteObject(bucket, object string) error { defer resp.Body.Close() if resp != nil { if resp.StatusCode != http.StatusOK { - return fmt.Errorf("%s", resp.Status) + var errorResponse ErrorResponse + switch { + case resp.StatusCode == http.StatusNotFound: + errorResponse = ErrorResponse{ + Code: "NoSuchKey", + Message: "The specified key does not exist.", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + case resp.StatusCode == http.StatusForbidden: + errorResponse = ErrorResponse{ + Code: "AccessDenied", + Message: "Access Denied", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + } + return errorResponse } } return nil @@ -545,7 +595,24 @@ func (a lowLevelAPI) headObject(bucket, object string) (ObjectStat, error) { defer resp.Body.Close() if resp != nil { if resp.StatusCode != http.StatusOK { - return ObjectStat{}, fmt.Errorf("%s", resp.Status) + var errorResponse ErrorResponse + switch { + case resp.StatusCode == http.StatusNotFound: + errorResponse = ErrorResponse{ + Code: "NoSuchKey", + Message: "The specified key does not exist.", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + case resp.StatusCode == http.StatusForbidden: + errorResponse = ErrorResponse{ + Code: "AccessDenied", + Message: "Access Denied", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + } + return ObjectStat{}, errorResponse } } md5sum := strings.Trim(resp.Header.Get("ETag"), "\"") // trim off the odd double quotes @@ -594,7 +661,7 @@ func (a lowLevelAPI) listBuckets() (listAllMyBucketsResult, error) { if resp != nil { // for un-authenticated requests, amazon sends a redirect handle it if resp.StatusCode == http.StatusTemporaryRedirect { - return listAllMyBucketsResult{}, fmt.Errorf("%s", resp.Status) + return listAllMyBucketsResult{}, errors.New(resp.Status) } if resp.StatusCode != http.StatusOK { return listAllMyBucketsResult{}, responseToError(resp.Body) diff --git a/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelmultipartapi.go b/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelmultipartapi.go index 7f043ed9..5b8b5fc1 100644 --- a/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelmultipartapi.go +++ b/Godeps/_workspace/src/github.com/minio/minio-go/lowlevelmultipartapi.go @@ -230,7 +230,24 @@ func (a lowLevelAPI) abortMultipartUpload(bucket, object, uploadID string) error if resp != nil { if resp.StatusCode != http.StatusNoContent { // Abort has no response body, handle it - return fmt.Errorf("%s", resp.Status) + var errorResponse ErrorResponse + switch { + case resp.StatusCode == http.StatusNotFound: + errorResponse = ErrorResponse{ + Code: "NoSuchUpload", + Message: "The specified multipart upload does not exist.", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + case resp.StatusCode == http.StatusForbidden: + errorResponse = ErrorResponse{ + Code: "AccessDenied", + Message: "Access Denied", + Resource: "/" + bucket + "/" + object, + RequestID: resp.Header.Get("x-amz-request-id"), + } + } + return errorResponse } } return resp.Body.Close() diff --git a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go index f4938667..315f44c5 100644 --- a/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go +++ b/Godeps/_workspace/src/github.com/shiena/ansicolor/ansicolor_windows.go @@ -308,7 +308,7 @@ func (cw *ansiColorWriter) Write(p []byte) (int, error) { } if cw.state == outsideCsiCode { - nw, err = cw.w.Write(p[first:]) + nw, err = cw.w.Write(p[first:len(p)]) } return r + nw + nc, err diff --git a/Makefile b/Makefile index f84b6c5f..c3b01022 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,9 @@ release: getdeps verifiers @go run make.go install @mkdir -p $(HOME)/.mc +godepupdate: + @for i in $(grep ImportPath Godeps/Godeps.json | grep -v minio/mc | cut -f2 -d: | sed -e 's/,//' -e 's/^[ \t]*//' -e 's/[ \t]*$//' -e 's/\"//g'); do godep update $i; done + save: @godep save ./...