From d08f0edcf18c0a854c8bda6ac8e1ac41598b3639 Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Thu, 11 Dec 2014 22:24:25 -0800 Subject: [PATCH] Migrate references to consolidated v2 package Routes and errors are now all referenced from a single v2 package. This packages exports are acceptable for use in the server side as well as integration into docker core. --- api/v2/descriptors.go | 3 +++ api_test.go | 25 ++++++++++++------------- app.go | 18 +++++++++--------- app_test.go | 16 ++++++++-------- client/client.go | 26 +++++++++++++------------- client/objectstore.go | 5 ++--- client/push.go | 7 +++---- cmd/registry-api-doctable-gen/main.go | 6 +++--- context.go | 7 +++---- images.go | 16 ++++++++-------- layer.go | 8 ++++---- layerupload.go | 24 ++++++++++++------------ tags.go | 4 ++-- 13 files changed, 82 insertions(+), 83 deletions(-) diff --git a/api/v2/descriptors.go b/api/v2/descriptors.go index 77528d723..68d182411 100644 --- a/api/v2/descriptors.go +++ b/api/v2/descriptors.go @@ -2,6 +2,9 @@ package v2 import "net/http" +// TODO(stevvooe): Add route descriptors for each named route, along with +// accepted methods, parameters, returned status codes and error codes. + // ErrorDescriptor provides relevant information about a given error code. type ErrorDescriptor struct { // Code is the error code that this descriptor describes. diff --git a/api_test.go b/api_test.go index e71edc17c..a650a1026 100644 --- a/api_test.go +++ b/api_test.go @@ -13,8 +13,7 @@ import ( "os" "testing" - "github.com/docker/docker-registry/api/errors" - "github.com/docker/docker-registry/api/urls" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/common/testutil" "github.com/docker/docker-registry/configuration" "github.com/docker/docker-registry/digest" @@ -35,7 +34,7 @@ func TestCheckAPI(t *testing.T) { app := NewApp(config) server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) - builder, err := urls.NewURLBuilderFromString(server.URL) + builder, err := v2.NewURLBuilderFromString(server.URL) if err != nil { t.Fatalf("error creating url builder: %v", err) @@ -82,7 +81,7 @@ func TestLayerAPI(t *testing.T) { app := NewApp(config) server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) - builder, err := urls.NewURLBuilderFromString(server.URL) + builder, err := v2.NewURLBuilderFromString(server.URL) if err != nil { t.Fatalf("error creating url builder: %v", err) @@ -197,7 +196,7 @@ func TestManifestAPI(t *testing.T) { app := NewApp(config) server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) - builder, err := urls.NewURLBuilderFromString(server.URL) + builder, err := v2.NewURLBuilderFromString(server.URL) if err != nil { t.Fatalf("unexpected error creating url builder: %v", err) } @@ -228,7 +227,7 @@ func TestManifestAPI(t *testing.T) { // } dec := json.NewDecoder(resp.Body) - var respErrs errors.Errors + var respErrs v2.Errors if err := dec.Decode(&respErrs); err != nil { t.Fatalf("unexpected error decoding error response: %v", err) } @@ -237,7 +236,7 @@ func TestManifestAPI(t *testing.T) { t.Fatalf("expected errors in response") } - if respErrs.Errors[0].Code != errors.ErrorCodeManifestUnknown { + if respErrs.Errors[0].Code != v2.ErrorCodeManifestUnknown { t.Fatalf("expected manifest unknown error: got %v", respErrs) } @@ -263,7 +262,7 @@ func TestManifestAPI(t *testing.T) { t.Fatalf("expected errors in response") } - if respErrs.Errors[0].Code != errors.ErrorCodeNameUnknown { + if respErrs.Errors[0].Code != v2.ErrorCodeNameUnknown { t.Fatalf("expected respository unknown error: got %v", respErrs) } @@ -297,11 +296,11 @@ func TestManifestAPI(t *testing.T) { for _, err := range respErrs.Errors { switch err.Code { - case errors.ErrorCodeManifestUnverified: + case v2.ErrorCodeManifestUnverified: unverified++ - case errors.ErrorCodeBlobUnknown: + case v2.ErrorCodeBlobUnknown: missingLayers++ - case errors.ErrorCodeDigestInvalid: + case v2.ErrorCodeDigestInvalid: // TODO(stevvooe): This error isn't quite descriptive enough -- // the layer with an invalid digest isn't identified. invalidDigests++ @@ -428,7 +427,7 @@ func putManifest(t *testing.T, msg, url string, v interface{}) *http.Response { return resp } -func startPushLayer(t *testing.T, ub *urls.URLBuilder, name string) string { +func startPushLayer(t *testing.T, ub *v2.URLBuilder, name string) string { layerUploadURL, err := ub.BuildBlobUploadURL(name) if err != nil { t.Fatalf("unexpected error building layer upload url: %v", err) @@ -450,7 +449,7 @@ func startPushLayer(t *testing.T, ub *urls.URLBuilder, name string) string { } // pushLayer pushes the layer content returning the url on success. -func pushLayer(t *testing.T, ub *urls.URLBuilder, name string, dgst digest.Digest, uploadURLBase string, rs io.ReadSeeker) string { +func pushLayer(t *testing.T, ub *v2.URLBuilder, name string, dgst digest.Digest, uploadURLBase string, rs io.ReadSeeker) string { rsLength, _ := rs.Seek(0, os.SEEK_END) rs.Seek(0, os.SEEK_SET) diff --git a/app.go b/app.go index e1b299a7a..5a770c6cd 100644 --- a/app.go +++ b/app.go @@ -4,7 +4,7 @@ import ( "fmt" "net/http" - "github.com/docker/docker-registry/api/urls" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/storagedriver" "github.com/docker/docker-registry/storagedriver/factory" @@ -36,18 +36,18 @@ type App struct { func NewApp(configuration configuration.Configuration) *App { app := &App{ Config: configuration, - router: urls.Router(), + router: v2.Router(), } // Register the handler dispatchers. - app.register(urls.RouteNameBase, func(ctx *Context, r *http.Request) http.Handler { + app.register(v2.RouteNameBase, func(ctx *Context, r *http.Request) http.Handler { return http.HandlerFunc(apiBase) }) - app.register(urls.RouteNameManifest, imageManifestDispatcher) - app.register(urls.RouteNameTags, tagsDispatcher) - app.register(urls.RouteNameBlob, layerDispatcher) - app.register(urls.RouteNameBlobUpload, layerUploadDispatcher) - app.register(urls.RouteNameBlobUploadChunk, layerUploadDispatcher) + app.register(v2.RouteNameManifest, imageManifestDispatcher) + app.register(v2.RouteNameTags, tagsDispatcher) + app.register(v2.RouteNameBlob, layerDispatcher) + app.register(v2.RouteNameBlobUpload, layerUploadDispatcher) + app.register(v2.RouteNameBlobUploadChunk, layerUploadDispatcher) driver, err := factory.Create(configuration.Storage.Type(), configuration.Storage.Parameters()) @@ -115,7 +115,7 @@ func (app *App) dispatcher(dispatch dispatchFunc) http.Handler { context := &Context{ App: app, Name: vars["name"], - urlBuilder: urls.NewURLBuilderFromRequest(r), + urlBuilder: v2.NewURLBuilderFromRequest(r), } // Store vars for underlying handlers. diff --git a/app_test.go b/app_test.go index eb8ec5971..f256c968d 100644 --- a/app_test.go +++ b/app_test.go @@ -6,7 +6,7 @@ import ( "net/url" "testing" - "github.com/docker/docker-registry/api/urls" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/configuration" ) @@ -17,10 +17,10 @@ import ( func TestAppDispatcher(t *testing.T) { app := &App{ Config: configuration.Configuration{}, - router: urls.Router(), + router: v2.Router(), } server := httptest.NewServer(app) - router := urls.Router() + router := v2.Router() serverURL, err := url.Parse(server.URL) if err != nil { @@ -72,33 +72,33 @@ func TestAppDispatcher(t *testing.T) { vars []string }{ { - endpoint: urls.RouteNameManifest, + endpoint: v2.RouteNameManifest, vars: []string{ "name", "foo/bar", "tag", "sometag", }, }, { - endpoint: urls.RouteNameTags, + endpoint: v2.RouteNameTags, vars: []string{ "name", "foo/bar", }, }, { - endpoint: urls.RouteNameBlob, + endpoint: v2.RouteNameBlob, vars: []string{ "name", "foo/bar", "digest", "tarsum.v1+bogus:abcdef0123456789", }, }, { - endpoint: urls.RouteNameBlobUpload, + endpoint: v2.RouteNameBlobUpload, vars: []string{ "name", "foo/bar", }, }, { - endpoint: urls.RouteNameBlobUploadChunk, + endpoint: v2.RouteNameBlobUploadChunk, vars: []string{ "name", "foo/bar", "uuid", "theuuid", diff --git a/client/client.go b/client/client.go index 8f31cb4e0..e25fbff4b 100644 --- a/client/client.go +++ b/client/client.go @@ -10,7 +10,7 @@ import ( "regexp" "strconv" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/digest" "github.com/docker/docker-registry/storage" ) @@ -96,7 +96,7 @@ func (r *clientImpl) GetImageManifest(name, tag string) (*storage.SignedManifest case response.StatusCode == http.StatusNotFound: return nil, &ImageManifestNotFoundError{Name: name, Tag: tag} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) @@ -136,7 +136,7 @@ func (r *clientImpl) PutImageManifest(name, tag string, manifest *storage.Signed case response.StatusCode == http.StatusOK: return nil case response.StatusCode >= 400 && response.StatusCode < 500: - var errors errors.Errors + var errors v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errors) if err != nil { @@ -169,7 +169,7 @@ func (r *clientImpl) DeleteImage(name, tag string) error { case response.StatusCode == http.StatusNotFound: return &ImageManifestNotFoundError{Name: name, Tag: tag} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -197,7 +197,7 @@ func (r *clientImpl) ListImageTags(name string) ([]string, error) { case response.StatusCode == http.StatusNotFound: return nil, &RepositoryNotFoundError{Name: name} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -240,7 +240,7 @@ func (r *clientImpl) BlobLength(name string, dgst digest.Digest) (int, error) { case response.StatusCode == http.StatusNotFound: return -1, nil case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -279,7 +279,7 @@ func (r *clientImpl) GetBlob(name string, dgst digest.Digest, byteOffset int) (i response.Body.Close() return nil, 0, &BlobNotFoundError{Name: name, Digest: dgst} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -312,7 +312,7 @@ func (r *clientImpl) InitiateBlobUpload(name string) (string, error) { // case response.StatusCode == http.StatusNotFound: // return case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -338,7 +338,7 @@ func (r *clientImpl) GetBlobUploadStatus(location string) (int, int, error) { case response.StatusCode == http.StatusNotFound: return 0, 0, &BlobUploadNotFoundError{Location: location} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -379,7 +379,7 @@ func (r *clientImpl) UploadBlob(location string, blob io.ReadCloser, length int, case response.StatusCode == http.StatusNotFound: return &BlobUploadNotFoundError{Location: location} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -430,7 +430,7 @@ func (r *clientImpl) UploadBlobChunk(location string, blobChunk io.ReadCloser, l case response.StatusCode == http.StatusNotFound: return &BlobUploadNotFoundError{Location: location} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -472,7 +472,7 @@ func (r *clientImpl) FinishChunkedBlobUpload(location string, length int, dgst d case response.StatusCode == http.StatusNotFound: return &BlobUploadNotFoundError{Location: location} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { @@ -504,7 +504,7 @@ func (r *clientImpl) CancelBlobUpload(location string) error { case response.StatusCode == http.StatusNotFound: return &BlobUploadNotFoundError{Location: location} case response.StatusCode >= 400 && response.StatusCode < 500: - var errs errors.Errors + var errs v2.Errors decoder := json.NewDecoder(response.Body) err = decoder.Decode(&errs) if err != nil { diff --git a/client/objectstore.go b/client/objectstore.go index 06fba3d8d..55ab20a55 100644 --- a/client/objectstore.go +++ b/client/objectstore.go @@ -2,7 +2,6 @@ package client import ( "bytes" - "errors" "fmt" "io" "sync" @@ -14,11 +13,11 @@ import ( var ( // ErrLayerAlreadyExists is returned when attempting to create a layer with // a tarsum that is already in use. - ErrLayerAlreadyExists = errors.New("Layer already exists") + ErrLayerAlreadyExists = fmt.Errorf("Layer already exists") // ErrLayerLocked is returned when attempting to write to a layer which is // currently being written to. - ErrLayerLocked = errors.New("Layer locked") + ErrLayerLocked = fmt.Errorf("Layer locked") ) // ObjectStore is an interface which is designed to approximate the docker diff --git a/client/push.go b/client/push.go index 61853b53c..aac3fc401 100644 --- a/client/push.go +++ b/client/push.go @@ -1,11 +1,10 @@ package client import ( - "errors" - - "github.com/docker/docker-registry/storage" + "fmt" log "github.com/Sirupsen/logrus" + "github.com/docker/docker-registry/storage" ) // simultaneousLayerPushWindow is the size of the parallel layer push window. @@ -100,7 +99,7 @@ func pushLayer(c Client, objectStore ObjectStore, name string, fsLayer storage.F "currentSize": layerReader.CurrentSize(), "size": layerReader.Size(), }).Warn("Local layer incomplete") - return errors.New("Local layer incomplete") + return fmt.Errorf("Local layer incomplete") } length, err := c.BlobLength(name, fsLayer.BlobSum) diff --git a/cmd/registry-api-doctable-gen/main.go b/cmd/registry-api-doctable-gen/main.go index 869f1a374..a9e71ffff 100644 --- a/cmd/registry-api-doctable-gen/main.go +++ b/cmd/registry-api-doctable-gen/main.go @@ -17,7 +17,7 @@ import ( "strings" "text/tabwriter" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" ) func main() { @@ -40,7 +40,7 @@ func dumpErrors(wr io.Writer) { defer writer.Flush() fmt.Fprint(writer, "|") - dtype := reflect.TypeOf(errors.ErrorDescriptor{}) + dtype := reflect.TypeOf(v2.ErrorDescriptor{}) var fieldsPrinted int for i := 0; i < dtype.NumField(); i++ { field := dtype.Field(i) @@ -61,7 +61,7 @@ func dumpErrors(wr io.Writer) { fmt.Fprintln(writer, "\n"+divider) - for _, descriptor := range errors.ErrorDescriptors { + for _, descriptor := range v2.ErrorDescriptors { fmt.Fprint(writer, "|") v := reflect.ValueOf(descriptor) diff --git a/context.go b/context.go index 23d669b85..0c5ba5870 100644 --- a/context.go +++ b/context.go @@ -2,8 +2,7 @@ package registry import ( "github.com/Sirupsen/logrus" - "github.com/docker/docker-registry/api/errors" - "github.com/docker/docker-registry/api/urls" + "github.com/docker/docker-registry/api/v2" ) // Context should contain the request specific context for use in across @@ -20,7 +19,7 @@ type Context struct { // Errors is a collection of errors encountered during the request to be // returned to the client API. If errors are added to the collection, the // handler *must not* start the response via http.ResponseWriter. - Errors errors.Errors + Errors v2.Errors // vars contains the extracted gorilla/mux variables that can be used for // assignment. @@ -29,5 +28,5 @@ type Context struct { // log provides a context specific logger. log *logrus.Entry - urlBuilder *urls.URLBuilder + urlBuilder *v2.URLBuilder } diff --git a/images.go b/images.go index 74ae067e8..5a373f1f6 100644 --- a/images.go +++ b/images.go @@ -5,7 +5,7 @@ import ( "fmt" "net/http" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/digest" "github.com/docker/docker-registry/storage" "github.com/gorilla/handlers" @@ -41,7 +41,7 @@ func (imh *imageManifestHandler) GetImageManifest(w http.ResponseWriter, r *http manifest, err := manifests.Get(imh.Name, imh.Tag) if err != nil { - imh.Errors.Push(errors.ErrorCodeManifestUnknown, err) + imh.Errors.Push(v2.ErrorCodeManifestUnknown, err) w.WriteHeader(http.StatusNotFound) return } @@ -58,7 +58,7 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http var manifest storage.SignedManifest if err := dec.Decode(&manifest); err != nil { - imh.Errors.Push(errors.ErrorCodeManifestInvalid, err) + imh.Errors.Push(v2.ErrorCodeManifestInvalid, err) w.WriteHeader(http.StatusBadRequest) return } @@ -71,14 +71,14 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http for _, verificationError := range err { switch verificationError := verificationError.(type) { case storage.ErrUnknownLayer: - imh.Errors.Push(errors.ErrorCodeBlobUnknown, verificationError.FSLayer) + imh.Errors.Push(v2.ErrorCodeBlobUnknown, verificationError.FSLayer) case storage.ErrManifestUnverified: - imh.Errors.Push(errors.ErrorCodeManifestUnverified) + imh.Errors.Push(v2.ErrorCodeManifestUnverified) default: if verificationError == digest.ErrDigestInvalidFormat { // TODO(stevvooe): We need to really need to move all // errors to types. Its much more straightforward. - imh.Errors.Push(errors.ErrorCodeDigestInvalid) + imh.Errors.Push(v2.ErrorCodeDigestInvalid) } else { imh.Errors.PushErr(verificationError) } @@ -99,10 +99,10 @@ func (imh *imageManifestHandler) DeleteImageManifest(w http.ResponseWriter, r *h if err := manifests.Delete(imh.Name, imh.Tag); err != nil { switch err := err.(type) { case storage.ErrUnknownManifest: - imh.Errors.Push(errors.ErrorCodeManifestUnknown, err) + imh.Errors.Push(v2.ErrorCodeManifestUnknown, err) w.WriteHeader(http.StatusNotFound) default: - imh.Errors.Push(errors.ErrorCodeUnknown, err) + imh.Errors.Push(v2.ErrorCodeUnknown, err) w.WriteHeader(http.StatusBadRequest) } return diff --git a/layer.go b/layer.go index 4da7723af..094a54cf4 100644 --- a/layer.go +++ b/layer.go @@ -3,7 +3,7 @@ package registry import ( "net/http" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/digest" "github.com/docker/docker-registry/storage" "github.com/gorilla/handlers" @@ -15,7 +15,7 @@ func layerDispatcher(ctx *Context, r *http.Request) http.Handler { if err != nil { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx.Errors.Push(errors.ErrorCodeDigestInvalid, err) + ctx.Errors.Push(v2.ErrorCodeDigestInvalid, err) }) } @@ -50,9 +50,9 @@ func (lh *layerHandler) GetLayer(w http.ResponseWriter, r *http.Request) { switch err := err.(type) { case storage.ErrUnknownLayer: w.WriteHeader(http.StatusNotFound) - lh.Errors.Push(errors.ErrorCodeBlobUnknown, err.FSLayer) + lh.Errors.Push(v2.ErrorCodeBlobUnknown, err.FSLayer) default: - lh.Errors.Push(errors.ErrorCodeUnknown, err) + lh.Errors.Push(v2.ErrorCodeUnknown, err) } return } diff --git a/layerupload.go b/layerupload.go index 898b279b7..b65c8ef2f 100644 --- a/layerupload.go +++ b/layerupload.go @@ -7,7 +7,7 @@ import ( "strconv" "github.com/Sirupsen/logrus" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/digest" "github.com/docker/docker-registry/storage" "github.com/gorilla/handlers" @@ -39,7 +39,7 @@ func layerUploadDispatcher(ctx *Context, r *http.Request) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { logrus.Infof("error resolving upload: %v", err) w.WriteHeader(http.StatusInternalServerError) - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) }) } @@ -67,7 +67,7 @@ func (luh *layerUploadHandler) StartLayerUpload(w http.ResponseWriter, r *http.R upload, err := layers.Upload(luh.Name) if err != nil { w.WriteHeader(http.StatusInternalServerError) // Error conditions here? - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) return } @@ -76,7 +76,7 @@ func (luh *layerUploadHandler) StartLayerUpload(w http.ResponseWriter, r *http.R if err := luh.layerUploadResponse(w, r); err != nil { w.WriteHeader(http.StatusInternalServerError) // Error conditions here? - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) return } w.WriteHeader(http.StatusAccepted) @@ -86,12 +86,12 @@ func (luh *layerUploadHandler) StartLayerUpload(w http.ResponseWriter, r *http.R func (luh *layerUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Request) { if luh.Upload == nil { w.WriteHeader(http.StatusNotFound) - luh.Errors.Push(errors.ErrorCodeBlobUploadUnknown) + luh.Errors.Push(v2.ErrorCodeBlobUploadUnknown) } if err := luh.layerUploadResponse(w, r); err != nil { w.WriteHeader(http.StatusInternalServerError) // Error conditions here? - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) return } @@ -103,7 +103,7 @@ func (luh *layerUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Re func (luh *layerUploadHandler) PutLayerChunk(w http.ResponseWriter, r *http.Request) { if luh.Upload == nil { w.WriteHeader(http.StatusNotFound) - luh.Errors.Push(errors.ErrorCodeBlobUploadUnknown) + luh.Errors.Push(v2.ErrorCodeBlobUploadUnknown) } var finished bool @@ -120,14 +120,14 @@ func (luh *layerUploadHandler) PutLayerChunk(w http.ResponseWriter, r *http.Requ if err := luh.maybeCompleteUpload(w, r); err != nil { if err != errNotReadyToComplete { w.WriteHeader(http.StatusInternalServerError) - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) return } } if err := luh.layerUploadResponse(w, r); err != nil { w.WriteHeader(http.StatusInternalServerError) // Error conditions here? - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) return } @@ -142,7 +142,7 @@ func (luh *layerUploadHandler) PutLayerChunk(w http.ResponseWriter, r *http.Requ func (luh *layerUploadHandler) CancelLayerUpload(w http.ResponseWriter, r *http.Request) { if luh.Upload == nil { w.WriteHeader(http.StatusNotFound) - luh.Errors.Push(errors.ErrorCodeBlobUploadUnknown) + luh.Errors.Push(v2.ErrorCodeBlobUploadUnknown) } } @@ -195,14 +195,14 @@ func (luh *layerUploadHandler) maybeCompleteUpload(w http.ResponseWriter, r *htt func (luh *layerUploadHandler) completeUpload(w http.ResponseWriter, r *http.Request, size int64, dgst digest.Digest) { layer, err := luh.Upload.Finish(size, dgst) if err != nil { - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) w.WriteHeader(http.StatusInternalServerError) return } layerURL, err := luh.urlBuilder.BuildBlobURL(layer.Name(), layer.Digest()) if err != nil { - luh.Errors.Push(errors.ErrorCodeUnknown, err) + luh.Errors.Push(v2.ErrorCodeUnknown, err) w.WriteHeader(http.StatusInternalServerError) return } diff --git a/tags.go b/tags.go index 12a5062f0..04d994b97 100644 --- a/tags.go +++ b/tags.go @@ -4,7 +4,7 @@ import ( "encoding/json" "net/http" - "github.com/docker/docker-registry/api/errors" + "github.com/docker/docker-registry/api/v2" "github.com/docker/docker-registry/storage" "github.com/gorilla/handlers" ) @@ -40,7 +40,7 @@ func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) { switch err := err.(type) { case storage.ErrUnknownRepository: w.WriteHeader(404) - th.Errors.Push(errors.ErrorCodeNameUnknown, map[string]string{"name": th.Name}) + th.Errors.Push(v2.ErrorCodeNameUnknown, map[string]string{"name": th.Name}) default: th.Errors.PushErr(err) }