Fixes "go vet" for drone CI

Removes "go get" commands for go cmd packages to use the default
versions
Also updates client/client.go to conform to go vet style
This commit is contained in:
Brian Bland 2014-11-17 13:07:58 -08:00
parent 3127ffcfb1
commit 8ad7819b1b
2 changed files with 28 additions and 27 deletions

View file

@ -5,9 +5,6 @@ env:
- PATH=$PATH:$GOROOT/bin:$GOPATH/bin - PATH=$PATH:$GOROOT/bin:$GOPATH/bin
script: script:
- go get code.google.com/p/go.tools/cmd/vet
- go get code.google.com/p/go.tools/cmd/godoc
- go get code.google.com/p/go.tools/cmd/cover
- go get github.com/axw/gocov/gocov - go get github.com/axw/gocov/gocov
- go get github.com/mattn/goveralls - go get github.com/mattn/goveralls
- go get github.com/golang/lint/golint - go get github.com/golang/lint/golint
@ -15,7 +12,7 @@ script:
- go get -d -t ./... - go get -d -t ./...
- hack/validate_gofmt.sh - hack/validate_gofmt.sh
- goveralls -v -service drone.io -repotoken $COVERALLS_TOKEN - goveralls -v -service drone.io -repotoken {{COVERALLS_TOKEN}}
- go vet ./... - go vet ./...
- golint ./... - golint ./...
- go test -v ./... - go test -v ./...

View file

@ -90,7 +90,7 @@ func (r *clientImpl) GetImageManifest(name, tag string) (*registry.ImageManifest
case response.StatusCode == http.StatusOK: case response.StatusCode == http.StatusOK:
break break
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return nil, &registry.ImageManifestNotFoundError{name, tag} return nil, &registry.ImageManifestNotFoundError{Name: name, Tag: tag}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -100,7 +100,7 @@ func (r *clientImpl) GetImageManifest(name, tag string) (*registry.ImageManifest
} }
return nil, errors return nil, errors
default: default:
return nil, &registry.UnexpectedHttpStatusError{response.Status} return nil, &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -144,7 +144,7 @@ func (r *clientImpl) PutImageManifest(name, tag string, manifest *registry.Image
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -166,7 +166,7 @@ func (r *clientImpl) DeleteImage(name, tag string) error {
case response.StatusCode == http.StatusNoContent: case response.StatusCode == http.StatusNoContent:
break break
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return &registry.ImageManifestNotFoundError{name, tag} return &registry.ImageManifestNotFoundError{Name: name, Tag: tag}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -176,7 +176,7 @@ func (r *clientImpl) DeleteImage(name, tag string) error {
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
return nil return nil
@ -194,7 +194,7 @@ func (r *clientImpl) ListImageTags(name string) ([]string, error) {
case response.StatusCode == http.StatusOK: case response.StatusCode == http.StatusOK:
break break
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return nil, &registry.RepositoryNotFoundError{name} return nil, &registry.RepositoryNotFoundError{Name: name}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -204,7 +204,7 @@ func (r *clientImpl) ListImageTags(name string) ([]string, error) {
} }
return nil, errors return nil, errors
default: default:
return nil, &registry.UnexpectedHttpStatusError{response.Status} return nil, &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
tags := struct { tags := struct {
@ -234,7 +234,7 @@ func (r *clientImpl) GetImageLayer(name, tarsum string, byteOffset int) (io.Read
} }
if response.StatusCode == http.StatusNotFound { if response.StatusCode == http.StatusNotFound {
return nil, 0, &registry.LayerNotFoundError{name, tarsum} return nil, 0, &registry.LayerNotFoundError{Name: name, TarSum: tarsum}
} }
// TODO(bbland): handle other status codes, like 5xx errors // TODO(bbland): handle other status codes, like 5xx errors
switch { switch {
@ -247,7 +247,7 @@ func (r *clientImpl) GetImageLayer(name, tarsum string, byteOffset int) (io.Read
return response.Body, int(length), nil return response.Body, int(length), nil
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
response.Body.Close() response.Body.Close()
return nil, 0, &registry.LayerNotFoundError{name, tarsum} return nil, 0, &registry.LayerNotFoundError{Name: name, TarSum: tarsum}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -258,7 +258,7 @@ func (r *clientImpl) GetImageLayer(name, tarsum string, byteOffset int) (io.Read
return nil, 0, errors return nil, 0, errors
default: default:
response.Body.Close() response.Body.Close()
return nil, 0, &registry.UnexpectedHttpStatusError{response.Status} return nil, 0, &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -280,7 +280,7 @@ func (r *clientImpl) InitiateLayerUpload(name, tarsum string) (string, error) {
case response.StatusCode == http.StatusAccepted: case response.StatusCode == http.StatusAccepted:
return response.Header.Get("Location"), nil return response.Header.Get("Location"), nil
case response.StatusCode == http.StatusNotModified: case response.StatusCode == http.StatusNotModified:
return "", &registry.LayerAlreadyExistsError{name, tarsum} return "", &registry.LayerAlreadyExistsError{Name: name, TarSum: tarsum}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -290,7 +290,7 @@ func (r *clientImpl) InitiateLayerUpload(name, tarsum string) (string, error) {
} }
return "", errors return "", errors
default: default:
return "", &registry.UnexpectedHttpStatusError{response.Status} return "", &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -306,7 +306,7 @@ func (r *clientImpl) GetLayerUploadStatus(location string) (int, int, error) {
case response.StatusCode == http.StatusNoContent: case response.StatusCode == http.StatusNoContent:
return parseRangeHeader(response.Header.Get("Range")) return parseRangeHeader(response.Header.Get("Range"))
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return 0, 0, &registry.LayerUploadNotFoundError{location} return 0, 0, &registry.LayerUploadNotFoundError{Location: location}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -316,7 +316,7 @@ func (r *clientImpl) GetLayerUploadStatus(location string) (int, int, error) {
} }
return 0, 0, errors return 0, 0, errors
default: default:
return 0, 0, &registry.UnexpectedHttpStatusError{response.Status} return 0, 0, &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -348,7 +348,7 @@ func (r *clientImpl) UploadLayer(location string, layer io.ReadCloser, length in
case response.StatusCode == http.StatusCreated: case response.StatusCode == http.StatusCreated:
return nil return nil
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return &registry.LayerUploadNotFoundError{location} return &registry.LayerUploadNotFoundError{Location: location}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -358,7 +358,7 @@ func (r *clientImpl) UploadLayer(location string, layer io.ReadCloser, length in
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -393,9 +393,13 @@ func (r *clientImpl) UploadLayerChunk(location string, layerChunk io.ReadCloser,
if err != nil { if err != nil {
return err return err
} }
return &registry.LayerUploadInvalidRangeError{location, lastValidRange, layerSize} return &registry.LayerUploadInvalidRangeError{
Location: location,
LastValidRange: lastValidRange,
LayerSize: layerSize,
}
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return &registry.LayerUploadNotFoundError{location} return &registry.LayerUploadNotFoundError{Location: location}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -405,7 +409,7 @@ func (r *clientImpl) UploadLayerChunk(location string, layerChunk io.ReadCloser,
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -437,7 +441,7 @@ func (r *clientImpl) FinishChunkedLayerUpload(location string, length int, check
case response.StatusCode == http.StatusCreated: case response.StatusCode == http.StatusCreated:
return nil return nil
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return &registry.LayerUploadNotFoundError{location} return &registry.LayerUploadNotFoundError{Location: location}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -447,7 +451,7 @@ func (r *clientImpl) FinishChunkedLayerUpload(location string, length int, check
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }
@ -469,7 +473,7 @@ func (r *clientImpl) CancelLayerUpload(location string) error {
case response.StatusCode == http.StatusNoContent: case response.StatusCode == http.StatusNoContent:
return nil return nil
case response.StatusCode == http.StatusNotFound: case response.StatusCode == http.StatusNotFound:
return &registry.LayerUploadNotFoundError{location} return &registry.LayerUploadNotFoundError{Location: location}
case response.StatusCode >= 400 && response.StatusCode < 500: case response.StatusCode >= 400 && response.StatusCode < 500:
errors := new(registry.Errors) errors := new(registry.Errors)
decoder := json.NewDecoder(response.Body) decoder := json.NewDecoder(response.Body)
@ -479,7 +483,7 @@ func (r *clientImpl) CancelLayerUpload(location string) error {
} }
return errors return errors
default: default:
return &registry.UnexpectedHttpStatusError{response.Status} return &registry.UnexpectedHttpStatusError{Status: response.Status}
} }
} }