Lots of various golint fixes

Changes some names to match go conventions
Comments all exported methods
Removes dot imports
This commit is contained in:
Brian Bland 2014-11-17 15:44:07 -08:00
parent b5cf681458
commit 88795e0a14
19 changed files with 417 additions and 257 deletions

View file

@ -10,18 +10,43 @@ import (
type ErrorCode int
const (
// ErrorCodeUnknown is a catch-all for errors not defined below.
ErrorCodeUnknown ErrorCode = iota
// The following errors can happen during a layer upload.
// ErrorCodeInvalidChecksum is returned when uploading a layer if the
// provided checksum does not match the layer contents.
ErrorCodeInvalidChecksum
// ErrorCodeInvalidLength is returned when uploading a layer if the provided
// length does not match the content length.
ErrorCodeInvalidLength
// ErrorCodeInvalidTarsum is returned when the provided tarsum does not
// match the computed tarsum of the contents.
ErrorCodeInvalidTarsum
// The following errors can happen during manifest upload.
// ErrorCodeInvalidName is returned when the name in the manifest does not
// match the provided name.
ErrorCodeInvalidName
// ErrorCodeInvalidTag is returned when the tag in the manifest does not
// match the provided tag.
ErrorCodeInvalidTag
// ErrorCodeUnverifiedManifest is returned when the manifest fails signature
// validation.
ErrorCodeUnverifiedManifest
// ErrorCodeUnknownLayer is returned when the manifest references a
// nonexistent layer.
ErrorCodeUnknownLayer
// ErrorCodeUntrustedSignature is returned when the manifest is signed by an
// untrusted source.
ErrorCodeUntrustedSignature
)
@ -83,6 +108,7 @@ func (ec ErrorCode) String() string {
return s
}
// Message returned the human-readable error message for this error code.
func (ec ErrorCode) Message() string {
m, ok := errorCodesMessages[ec]
@ -93,16 +119,20 @@ func (ec ErrorCode) Message() string {
return m
}
// MarshalText encodes the receiver into UTF-8-encoded text and returns the
// result.
func (ec ErrorCode) MarshalText() (text []byte, err error) {
return []byte(ec.String()), nil
}
// UnmarshalText decodes the form generated by MarshalText.
func (ec *ErrorCode) UnmarshalText(text []byte) error {
*ec = stringToErrorCode[string(text)]
return nil
}
// Error provides a wrapper around ErrorCode with extra Details provided.
type Error struct {
Code ErrorCode `json:"code,omitempty"`
Message string `json:"message,omitempty"`
@ -173,7 +203,7 @@ type DetailUnknownLayer struct {
}
// RepositoryNotFoundError is returned when making an operation against a
// repository that does not exist in the registry
// repository that does not exist in the registry.
type RepositoryNotFoundError struct {
Name string
}
@ -183,7 +213,7 @@ func (e *RepositoryNotFoundError) Error() string {
}
// ImageManifestNotFoundError is returned when making an operation against a
// given image manifest that does not exist in the registry
// given image manifest that does not exist in the registry.
type ImageManifestNotFoundError struct {
Name string
Tag string
@ -195,7 +225,7 @@ func (e *ImageManifestNotFoundError) Error() string {
}
// LayerAlreadyExistsError is returned when attempting to create a new layer
// that already exists in the registry
// that already exists in the registry.
type LayerAlreadyExistsError struct {
Name string
TarSum string
@ -207,7 +237,7 @@ func (e *LayerAlreadyExistsError) Error() string {
}
// LayerNotFoundError is returned when making an operation against a given image
// layer that does not exist in the registry
// layer that does not exist in the registry.
type LayerNotFoundError struct {
Name string
TarSum string
@ -221,7 +251,7 @@ func (e *LayerNotFoundError) Error() string {
// LayerUploadNotFoundError is returned when making a layer upload operation
// against an invalid layer upload location url
// This may be the result of using a cancelled, completed, or stale upload
// locationn
// location.
type LayerUploadNotFoundError struct {
Location string
}
@ -232,9 +262,9 @@ func (e *LayerUploadNotFoundError) Error() string {
}
// LayerUploadInvalidRangeError is returned when attempting to upload an image
// layer chunk that is out of order
// layer chunk that is out of order.
// This provides the known LayerSize and LastValidRange which can be used to
// resume the upload
// resume the upload.
type LayerUploadInvalidRangeError struct {
Location string
LastValidRange int
@ -247,12 +277,12 @@ func (e *LayerUploadInvalidRangeError) Error() string {
e.Location, e.LastValidRange, e.LayerSize)
}
// UnexpectedHttpStatusError is returned when an unexpected http status is
// returned when making a registry api call
type UnexpectedHttpStatusError struct {
// UnexpectedHTTPStatusError is returned when an unexpected HTTP status is
// returned when making a registry api call.
type UnexpectedHTTPStatusError struct {
Status string
}
func (e *UnexpectedHttpStatusError) Error() string {
return fmt.Sprintf("Received unexpected http status: %s", e.Status)
func (e *UnexpectedHTTPStatusError) Error() string {
return fmt.Sprintf("Received unexpected HTTP status: %s", e.Status)
}