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.master
							parent
							
								
									5abfc91021
								
							
						
					
					
						commit
						d08f0edcf1
					
				|  | @ -2,6 +2,9 @@ package v2 | ||||||
| 
 | 
 | ||||||
| import "net/http" | 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.
 | // ErrorDescriptor provides relevant information about a given error code.
 | ||||||
| type ErrorDescriptor struct { | type ErrorDescriptor struct { | ||||||
| 	// Code is the error code that this descriptor describes.
 | 	// Code is the error code that this descriptor describes.
 | ||||||
|  |  | ||||||
							
								
								
									
										25
									
								
								api_test.go
								
								
								
								
							
							
						
						
									
										25
									
								
								api_test.go
								
								
								
								
							|  | @ -13,8 +13,7 @@ import ( | ||||||
| 	"os" | 	"os" | ||||||
| 	"testing" | 	"testing" | ||||||
| 
 | 
 | ||||||
| 	"github.com/docker/docker-registry/api/errors" | 	"github.com/docker/docker-registry/api/v2" | ||||||
| 	"github.com/docker/docker-registry/api/urls" |  | ||||||
| 	"github.com/docker/docker-registry/common/testutil" | 	"github.com/docker/docker-registry/common/testutil" | ||||||
| 	"github.com/docker/docker-registry/configuration" | 	"github.com/docker/docker-registry/configuration" | ||||||
| 	"github.com/docker/docker-registry/digest" | 	"github.com/docker/docker-registry/digest" | ||||||
|  | @ -35,7 +34,7 @@ func TestCheckAPI(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	app := NewApp(config) | 	app := NewApp(config) | ||||||
| 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | ||||||
| 	builder, err := urls.NewURLBuilderFromString(server.URL) | 	builder, err := v2.NewURLBuilderFromString(server.URL) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating url builder: %v", err) | 		t.Fatalf("error creating url builder: %v", err) | ||||||
|  | @ -82,7 +81,7 @@ func TestLayerAPI(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	app := NewApp(config) | 	app := NewApp(config) | ||||||
| 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | ||||||
| 	builder, err := urls.NewURLBuilderFromString(server.URL) | 	builder, err := v2.NewURLBuilderFromString(server.URL) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("error creating url builder: %v", err) | 		t.Fatalf("error creating url builder: %v", err) | ||||||
|  | @ -197,7 +196,7 @@ func TestManifestAPI(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	app := NewApp(config) | 	app := NewApp(config) | ||||||
| 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | 	server := httptest.NewServer(handlers.CombinedLoggingHandler(os.Stderr, app)) | ||||||
| 	builder, err := urls.NewURLBuilderFromString(server.URL) | 	builder, err := v2.NewURLBuilderFromString(server.URL) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error creating url builder: %v", err) | 		t.Fatalf("unexpected error creating url builder: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -228,7 +227,7 @@ func TestManifestAPI(t *testing.T) { | ||||||
| 	// }
 | 	// }
 | ||||||
| 	dec := json.NewDecoder(resp.Body) | 	dec := json.NewDecoder(resp.Body) | ||||||
| 
 | 
 | ||||||
| 	var respErrs errors.Errors | 	var respErrs v2.Errors | ||||||
| 	if err := dec.Decode(&respErrs); err != nil { | 	if err := dec.Decode(&respErrs); err != nil { | ||||||
| 		t.Fatalf("unexpected error decoding error response: %v", err) | 		t.Fatalf("unexpected error decoding error response: %v", err) | ||||||
| 	} | 	} | ||||||
|  | @ -237,7 +236,7 @@ func TestManifestAPI(t *testing.T) { | ||||||
| 		t.Fatalf("expected errors in response") | 		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) | 		t.Fatalf("expected manifest unknown error: got %v", respErrs) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -263,7 +262,7 @@ func TestManifestAPI(t *testing.T) { | ||||||
| 		t.Fatalf("expected errors in response") | 		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) | 		t.Fatalf("expected respository unknown error: got %v", respErrs) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -297,11 +296,11 @@ func TestManifestAPI(t *testing.T) { | ||||||
| 
 | 
 | ||||||
| 	for _, err := range respErrs.Errors { | 	for _, err := range respErrs.Errors { | ||||||
| 		switch err.Code { | 		switch err.Code { | ||||||
| 		case errors.ErrorCodeManifestUnverified: | 		case v2.ErrorCodeManifestUnverified: | ||||||
| 			unverified++ | 			unverified++ | ||||||
| 		case errors.ErrorCodeBlobUnknown: | 		case v2.ErrorCodeBlobUnknown: | ||||||
| 			missingLayers++ | 			missingLayers++ | ||||||
| 		case errors.ErrorCodeDigestInvalid: | 		case v2.ErrorCodeDigestInvalid: | ||||||
| 			// TODO(stevvooe): This error isn't quite descriptive enough --
 | 			// TODO(stevvooe): This error isn't quite descriptive enough --
 | ||||||
| 			// the layer with an invalid digest isn't identified.
 | 			// the layer with an invalid digest isn't identified.
 | ||||||
| 			invalidDigests++ | 			invalidDigests++ | ||||||
|  | @ -428,7 +427,7 @@ func putManifest(t *testing.T, msg, url string, v interface{}) *http.Response { | ||||||
| 	return resp | 	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) | 	layerUploadURL, err := ub.BuildBlobUploadURL(name) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		t.Fatalf("unexpected error building layer upload url: %v", err) | 		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.
 | // 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) | 	rsLength, _ := rs.Seek(0, os.SEEK_END) | ||||||
| 	rs.Seek(0, os.SEEK_SET) | 	rs.Seek(0, os.SEEK_SET) | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
							
								
								
									
										18
									
								
								app.go
								
								
								
								
							
							
						
						
									
										18
									
								
								app.go
								
								
								
								
							|  | @ -4,7 +4,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/http" | 	"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" | ||||||
| 	"github.com/docker/docker-registry/storagedriver/factory" | 	"github.com/docker/docker-registry/storagedriver/factory" | ||||||
| 
 | 
 | ||||||
|  | @ -36,18 +36,18 @@ type App struct { | ||||||
| func NewApp(configuration configuration.Configuration) *App { | func NewApp(configuration configuration.Configuration) *App { | ||||||
| 	app := &App{ | 	app := &App{ | ||||||
| 		Config: configuration, | 		Config: configuration, | ||||||
| 		router: urls.Router(), | 		router: v2.Router(), | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	// Register the handler dispatchers.
 | 	// 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) | 		return http.HandlerFunc(apiBase) | ||||||
| 	}) | 	}) | ||||||
| 	app.register(urls.RouteNameManifest, imageManifestDispatcher) | 	app.register(v2.RouteNameManifest, imageManifestDispatcher) | ||||||
| 	app.register(urls.RouteNameTags, tagsDispatcher) | 	app.register(v2.RouteNameTags, tagsDispatcher) | ||||||
| 	app.register(urls.RouteNameBlob, layerDispatcher) | 	app.register(v2.RouteNameBlob, layerDispatcher) | ||||||
| 	app.register(urls.RouteNameBlobUpload, layerUploadDispatcher) | 	app.register(v2.RouteNameBlobUpload, layerUploadDispatcher) | ||||||
| 	app.register(urls.RouteNameBlobUploadChunk, layerUploadDispatcher) | 	app.register(v2.RouteNameBlobUploadChunk, layerUploadDispatcher) | ||||||
| 
 | 
 | ||||||
| 	driver, err := factory.Create(configuration.Storage.Type(), configuration.Storage.Parameters()) | 	driver, err := factory.Create(configuration.Storage.Type(), configuration.Storage.Parameters()) | ||||||
| 
 | 
 | ||||||
|  | @ -115,7 +115,7 @@ func (app *App) dispatcher(dispatch dispatchFunc) http.Handler { | ||||||
| 		context := &Context{ | 		context := &Context{ | ||||||
| 			App:        app, | 			App:        app, | ||||||
| 			Name:       vars["name"], | 			Name:       vars["name"], | ||||||
| 			urlBuilder: urls.NewURLBuilderFromRequest(r), | 			urlBuilder: v2.NewURLBuilderFromRequest(r), | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		// Store vars for underlying handlers.
 | 		// Store vars for underlying handlers.
 | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								app_test.go
								
								
								
								
							
							
						
						
									
										16
									
								
								app_test.go
								
								
								
								
							|  | @ -6,7 +6,7 @@ import ( | ||||||
| 	"net/url" | 	"net/url" | ||||||
| 	"testing" | 	"testing" | ||||||
| 
 | 
 | ||||||
| 	"github.com/docker/docker-registry/api/urls" | 	"github.com/docker/docker-registry/api/v2" | ||||||
| 	"github.com/docker/docker-registry/configuration" | 	"github.com/docker/docker-registry/configuration" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
|  | @ -17,10 +17,10 @@ import ( | ||||||
| func TestAppDispatcher(t *testing.T) { | func TestAppDispatcher(t *testing.T) { | ||||||
| 	app := &App{ | 	app := &App{ | ||||||
| 		Config: configuration.Configuration{}, | 		Config: configuration.Configuration{}, | ||||||
| 		router: urls.Router(), | 		router: v2.Router(), | ||||||
| 	} | 	} | ||||||
| 	server := httptest.NewServer(app) | 	server := httptest.NewServer(app) | ||||||
| 	router := urls.Router() | 	router := v2.Router() | ||||||
| 
 | 
 | ||||||
| 	serverURL, err := url.Parse(server.URL) | 	serverURL, err := url.Parse(server.URL) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  | @ -72,33 +72,33 @@ func TestAppDispatcher(t *testing.T) { | ||||||
| 		vars     []string | 		vars     []string | ||||||
| 	}{ | 	}{ | ||||||
| 		{ | 		{ | ||||||
| 			endpoint: urls.RouteNameManifest, | 			endpoint: v2.RouteNameManifest, | ||||||
| 			vars: []string{ | 			vars: []string{ | ||||||
| 				"name", "foo/bar", | 				"name", "foo/bar", | ||||||
| 				"tag", "sometag", | 				"tag", "sometag", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			endpoint: urls.RouteNameTags, | 			endpoint: v2.RouteNameTags, | ||||||
| 			vars: []string{ | 			vars: []string{ | ||||||
| 				"name", "foo/bar", | 				"name", "foo/bar", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			endpoint: urls.RouteNameBlob, | 			endpoint: v2.RouteNameBlob, | ||||||
| 			vars: []string{ | 			vars: []string{ | ||||||
| 				"name", "foo/bar", | 				"name", "foo/bar", | ||||||
| 				"digest", "tarsum.v1+bogus:abcdef0123456789", | 				"digest", "tarsum.v1+bogus:abcdef0123456789", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			endpoint: urls.RouteNameBlobUpload, | 			endpoint: v2.RouteNameBlobUpload, | ||||||
| 			vars: []string{ | 			vars: []string{ | ||||||
| 				"name", "foo/bar", | 				"name", "foo/bar", | ||||||
| 			}, | 			}, | ||||||
| 		}, | 		}, | ||||||
| 		{ | 		{ | ||||||
| 			endpoint: urls.RouteNameBlobUploadChunk, | 			endpoint: v2.RouteNameBlobUploadChunk, | ||||||
| 			vars: []string{ | 			vars: []string{ | ||||||
| 				"name", "foo/bar", | 				"name", "foo/bar", | ||||||
| 				"uuid", "theuuid", | 				"uuid", "theuuid", | ||||||
|  |  | ||||||
|  | @ -10,7 +10,7 @@ import ( | ||||||
| 	"regexp" | 	"regexp" | ||||||
| 	"strconv" | 	"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/digest" | ||||||
| 	"github.com/docker/docker-registry/storage" | 	"github.com/docker/docker-registry/storage" | ||||||
| ) | ) | ||||||
|  | @ -96,7 +96,7 @@ func (r *clientImpl) GetImageManifest(name, tag string) (*storage.SignedManifest | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return nil, &ImageManifestNotFoundError{Name: name, Tag: tag} | 		return nil, &ImageManifestNotFoundError{Name: name, Tag: tag} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 
 | 
 | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
|  | @ -136,7 +136,7 @@ func (r *clientImpl) PutImageManifest(name, tag string, manifest *storage.Signed | ||||||
| 	case response.StatusCode == http.StatusOK: | 	case response.StatusCode == http.StatusOK: | ||||||
| 		return nil | 		return nil | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errors errors.Errors | 		var errors v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errors) | 		err = decoder.Decode(&errors) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -169,7 +169,7 @@ func (r *clientImpl) DeleteImage(name, tag string) error { | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return &ImageManifestNotFoundError{Name: name, Tag: tag} | 		return &ImageManifestNotFoundError{Name: name, Tag: tag} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -197,7 +197,7 @@ func (r *clientImpl) ListImageTags(name string) ([]string, error) { | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return nil, &RepositoryNotFoundError{Name: name} | 		return nil, &RepositoryNotFoundError{Name: name} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -240,7 +240,7 @@ func (r *clientImpl) BlobLength(name string, dgst digest.Digest) (int, error) { | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return -1, nil | 		return -1, nil | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -279,7 +279,7 @@ func (r *clientImpl) GetBlob(name string, dgst digest.Digest, byteOffset int) (i | ||||||
| 		response.Body.Close() | 		response.Body.Close() | ||||||
| 		return nil, 0, &BlobNotFoundError{Name: name, Digest: dgst} | 		return nil, 0, &BlobNotFoundError{Name: name, Digest: dgst} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -312,7 +312,7 @@ func (r *clientImpl) InitiateBlobUpload(name string) (string, error) { | ||||||
| 	// case response.StatusCode == http.StatusNotFound:
 | 	// case response.StatusCode == http.StatusNotFound:
 | ||||||
| 	// return
 | 	// return
 | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -338,7 +338,7 @@ func (r *clientImpl) GetBlobUploadStatus(location string) (int, int, error) { | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return 0, 0, &BlobUploadNotFoundError{Location: location} | 		return 0, 0, &BlobUploadNotFoundError{Location: location} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -379,7 +379,7 @@ func (r *clientImpl) UploadBlob(location string, blob io.ReadCloser, length int, | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return &BlobUploadNotFoundError{Location: location} | 		return &BlobUploadNotFoundError{Location: location} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -430,7 +430,7 @@ func (r *clientImpl) UploadBlobChunk(location string, blobChunk io.ReadCloser, l | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return &BlobUploadNotFoundError{Location: location} | 		return &BlobUploadNotFoundError{Location: location} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -472,7 +472,7 @@ func (r *clientImpl) FinishChunkedBlobUpload(location string, length int, dgst d | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return &BlobUploadNotFoundError{Location: location} | 		return &BlobUploadNotFoundError{Location: location} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  | @ -504,7 +504,7 @@ func (r *clientImpl) CancelBlobUpload(location string) error { | ||||||
| 	case response.StatusCode == http.StatusNotFound: | 	case response.StatusCode == http.StatusNotFound: | ||||||
| 		return &BlobUploadNotFoundError{Location: location} | 		return &BlobUploadNotFoundError{Location: location} | ||||||
| 	case response.StatusCode >= 400 && response.StatusCode < 500: | 	case response.StatusCode >= 400 && response.StatusCode < 500: | ||||||
| 		var errs errors.Errors | 		var errs v2.Errors | ||||||
| 		decoder := json.NewDecoder(response.Body) | 		decoder := json.NewDecoder(response.Body) | ||||||
| 		err = decoder.Decode(&errs) | 		err = decoder.Decode(&errs) | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ package client | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"bytes" | 	"bytes" | ||||||
| 	"errors" |  | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"sync" | 	"sync" | ||||||
|  | @ -14,11 +13,11 @@ import ( | ||||||
| var ( | var ( | ||||||
| 	// ErrLayerAlreadyExists is returned when attempting to create a layer with
 | 	// ErrLayerAlreadyExists is returned when attempting to create a layer with
 | ||||||
| 	// a tarsum that is already in use.
 | 	// 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
 | 	// ErrLayerLocked is returned when attempting to write to a layer which is
 | ||||||
| 	// currently being written to.
 | 	// 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
 | // ObjectStore is an interface which is designed to approximate the docker
 | ||||||
|  |  | ||||||
|  | @ -1,11 +1,10 @@ | ||||||
| package client | package client | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"errors" | 	"fmt" | ||||||
| 
 |  | ||||||
| 	"github.com/docker/docker-registry/storage" |  | ||||||
| 
 | 
 | ||||||
| 	log "github.com/Sirupsen/logrus" | 	log "github.com/Sirupsen/logrus" | ||||||
|  | 	"github.com/docker/docker-registry/storage" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // simultaneousLayerPushWindow is the size of the parallel layer push window.
 | // 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(), | 			"currentSize": layerReader.CurrentSize(), | ||||||
| 			"size":        layerReader.Size(), | 			"size":        layerReader.Size(), | ||||||
| 		}).Warn("Local layer incomplete") | 		}).Warn("Local layer incomplete") | ||||||
| 		return errors.New("Local layer incomplete") | 		return fmt.Errorf("Local layer incomplete") | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	length, err := c.BlobLength(name, fsLayer.BlobSum) | 	length, err := c.BlobLength(name, fsLayer.BlobSum) | ||||||
|  |  | ||||||
|  | @ -17,7 +17,7 @@ import ( | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"text/tabwriter" | 	"text/tabwriter" | ||||||
| 
 | 
 | ||||||
| 	"github.com/docker/docker-registry/api/errors" | 	"github.com/docker/docker-registry/api/v2" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func main() { | func main() { | ||||||
|  | @ -40,7 +40,7 @@ func dumpErrors(wr io.Writer) { | ||||||
| 	defer writer.Flush() | 	defer writer.Flush() | ||||||
| 
 | 
 | ||||||
| 	fmt.Fprint(writer, "|") | 	fmt.Fprint(writer, "|") | ||||||
| 	dtype := reflect.TypeOf(errors.ErrorDescriptor{}) | 	dtype := reflect.TypeOf(v2.ErrorDescriptor{}) | ||||||
| 	var fieldsPrinted int | 	var fieldsPrinted int | ||||||
| 	for i := 0; i < dtype.NumField(); i++ { | 	for i := 0; i < dtype.NumField(); i++ { | ||||||
| 		field := dtype.Field(i) | 		field := dtype.Field(i) | ||||||
|  | @ -61,7 +61,7 @@ func dumpErrors(wr io.Writer) { | ||||||
| 
 | 
 | ||||||
| 	fmt.Fprintln(writer, "\n"+divider) | 	fmt.Fprintln(writer, "\n"+divider) | ||||||
| 
 | 
 | ||||||
| 	for _, descriptor := range errors.ErrorDescriptors { | 	for _, descriptor := range v2.ErrorDescriptors { | ||||||
| 		fmt.Fprint(writer, "|") | 		fmt.Fprint(writer, "|") | ||||||
| 
 | 
 | ||||||
| 		v := reflect.ValueOf(descriptor) | 		v := reflect.ValueOf(descriptor) | ||||||
|  |  | ||||||
|  | @ -2,8 +2,7 @@ package registry | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	"github.com/Sirupsen/logrus" | 	"github.com/Sirupsen/logrus" | ||||||
| 	"github.com/docker/docker-registry/api/errors" | 	"github.com/docker/docker-registry/api/v2" | ||||||
| 	"github.com/docker/docker-registry/api/urls" |  | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| // Context should contain the request specific context for use in across
 | // 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
 | 	// 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
 | 	// returned to the client API. If errors are added to the collection, the
 | ||||||
| 	// handler *must not* start the response via http.ResponseWriter.
 | 	// 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
 | 	// vars contains the extracted gorilla/mux variables that can be used for
 | ||||||
| 	// assignment.
 | 	// assignment.
 | ||||||
|  | @ -29,5 +28,5 @@ type Context struct { | ||||||
| 	// log provides a context specific logger.
 | 	// log provides a context specific logger.
 | ||||||
| 	log *logrus.Entry | 	log *logrus.Entry | ||||||
| 
 | 
 | ||||||
| 	urlBuilder *urls.URLBuilder | 	urlBuilder *v2.URLBuilder | ||||||
| } | } | ||||||
|  |  | ||||||
							
								
								
									
										16
									
								
								images.go
								
								
								
								
							
							
						
						
									
										16
									
								
								images.go
								
								
								
								
							|  | @ -5,7 +5,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"net/http" | 	"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/digest" | ||||||
| 	"github.com/docker/docker-registry/storage" | 	"github.com/docker/docker-registry/storage" | ||||||
| 	"github.com/gorilla/handlers" | 	"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) | 	manifest, err := manifests.Get(imh.Name, imh.Tag) | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		imh.Errors.Push(errors.ErrorCodeManifestUnknown, err) | 		imh.Errors.Push(v2.ErrorCodeManifestUnknown, err) | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		w.WriteHeader(http.StatusNotFound) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | @ -58,7 +58,7 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http | ||||||
| 
 | 
 | ||||||
| 	var manifest storage.SignedManifest | 	var manifest storage.SignedManifest | ||||||
| 	if err := dec.Decode(&manifest); err != nil { | 	if err := dec.Decode(&manifest); err != nil { | ||||||
| 		imh.Errors.Push(errors.ErrorCodeManifestInvalid, err) | 		imh.Errors.Push(v2.ErrorCodeManifestInvalid, err) | ||||||
| 		w.WriteHeader(http.StatusBadRequest) | 		w.WriteHeader(http.StatusBadRequest) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  | @ -71,14 +71,14 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http | ||||||
| 			for _, verificationError := range err { | 			for _, verificationError := range err { | ||||||
| 				switch verificationError := verificationError.(type) { | 				switch verificationError := verificationError.(type) { | ||||||
| 				case storage.ErrUnknownLayer: | 				case storage.ErrUnknownLayer: | ||||||
| 					imh.Errors.Push(errors.ErrorCodeBlobUnknown, verificationError.FSLayer) | 					imh.Errors.Push(v2.ErrorCodeBlobUnknown, verificationError.FSLayer) | ||||||
| 				case storage.ErrManifestUnverified: | 				case storage.ErrManifestUnverified: | ||||||
| 					imh.Errors.Push(errors.ErrorCodeManifestUnverified) | 					imh.Errors.Push(v2.ErrorCodeManifestUnverified) | ||||||
| 				default: | 				default: | ||||||
| 					if verificationError == digest.ErrDigestInvalidFormat { | 					if verificationError == digest.ErrDigestInvalidFormat { | ||||||
| 						// TODO(stevvooe): We need to really need to move all
 | 						// TODO(stevvooe): We need to really need to move all
 | ||||||
| 						// errors to types. Its much more straightforward.
 | 						// errors to types. Its much more straightforward.
 | ||||||
| 						imh.Errors.Push(errors.ErrorCodeDigestInvalid) | 						imh.Errors.Push(v2.ErrorCodeDigestInvalid) | ||||||
| 					} else { | 					} else { | ||||||
| 						imh.Errors.PushErr(verificationError) | 						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 { | 	if err := manifests.Delete(imh.Name, imh.Tag); err != nil { | ||||||
| 		switch err := err.(type) { | 		switch err := err.(type) { | ||||||
| 		case storage.ErrUnknownManifest: | 		case storage.ErrUnknownManifest: | ||||||
| 			imh.Errors.Push(errors.ErrorCodeManifestUnknown, err) | 			imh.Errors.Push(v2.ErrorCodeManifestUnknown, err) | ||||||
| 			w.WriteHeader(http.StatusNotFound) | 			w.WriteHeader(http.StatusNotFound) | ||||||
| 		default: | 		default: | ||||||
| 			imh.Errors.Push(errors.ErrorCodeUnknown, err) | 			imh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 			w.WriteHeader(http.StatusBadRequest) | 			w.WriteHeader(http.StatusBadRequest) | ||||||
| 		} | 		} | ||||||
| 		return | 		return | ||||||
|  |  | ||||||
							
								
								
									
										8
									
								
								layer.go
								
								
								
								
							
							
						
						
									
										8
									
								
								layer.go
								
								
								
								
							|  | @ -3,7 +3,7 @@ package registry | ||||||
| import ( | import ( | ||||||
| 	"net/http" | 	"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/digest" | ||||||
| 	"github.com/docker/docker-registry/storage" | 	"github.com/docker/docker-registry/storage" | ||||||
| 	"github.com/gorilla/handlers" | 	"github.com/gorilla/handlers" | ||||||
|  | @ -15,7 +15,7 @@ func layerDispatcher(ctx *Context, r *http.Request) http.Handler { | ||||||
| 
 | 
 | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | 		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) { | 		switch err := err.(type) { | ||||||
| 		case storage.ErrUnknownLayer: | 		case storage.ErrUnknownLayer: | ||||||
| 			w.WriteHeader(http.StatusNotFound) | 			w.WriteHeader(http.StatusNotFound) | ||||||
| 			lh.Errors.Push(errors.ErrorCodeBlobUnknown, err.FSLayer) | 			lh.Errors.Push(v2.ErrorCodeBlobUnknown, err.FSLayer) | ||||||
| 		default: | 		default: | ||||||
| 			lh.Errors.Push(errors.ErrorCodeUnknown, err) | 			lh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		} | 		} | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | @ -7,7 +7,7 @@ import ( | ||||||
| 	"strconv" | 	"strconv" | ||||||
| 
 | 
 | ||||||
| 	"github.com/Sirupsen/logrus" | 	"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/digest" | ||||||
| 	"github.com/docker/docker-registry/storage" | 	"github.com/docker/docker-registry/storage" | ||||||
| 	"github.com/gorilla/handlers" | 	"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) { | 			return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||||||
| 				logrus.Infof("error resolving upload: %v", err) | 				logrus.Infof("error resolving upload: %v", err) | ||||||
| 				w.WriteHeader(http.StatusInternalServerError) | 				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) | 	upload, err := layers.Upload(luh.Name) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
|  | @ -76,7 +76,7 @@ func (luh *layerUploadHandler) StartLayerUpload(w http.ResponseWriter, r *http.R | ||||||
| 
 | 
 | ||||||
| 	if err := luh.layerUploadResponse(w, r); err != nil { | 	if err := luh.layerUploadResponse(w, r); err != nil { | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 	w.WriteHeader(http.StatusAccepted) | 	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) { | func (luh *layerUploadHandler) GetUploadStatus(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if luh.Upload == nil { | 	if luh.Upload == nil { | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		w.WriteHeader(http.StatusNotFound) | ||||||
| 		luh.Errors.Push(errors.ErrorCodeBlobUploadUnknown) | 		luh.Errors.Push(v2.ErrorCodeBlobUploadUnknown) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if err := luh.layerUploadResponse(w, r); err != nil { | 	if err := luh.layerUploadResponse(w, r); err != nil { | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		return | 		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) { | func (luh *layerUploadHandler) PutLayerChunk(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if luh.Upload == nil { | 	if luh.Upload == nil { | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		w.WriteHeader(http.StatusNotFound) | ||||||
| 		luh.Errors.Push(errors.ErrorCodeBlobUploadUnknown) | 		luh.Errors.Push(v2.ErrorCodeBlobUploadUnknown) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	var finished bool | 	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 := luh.maybeCompleteUpload(w, r); err != nil { | ||||||
| 		if err != errNotReadyToComplete { | 		if err != errNotReadyToComplete { | ||||||
| 			w.WriteHeader(http.StatusInternalServerError) | 			w.WriteHeader(http.StatusInternalServerError) | ||||||
| 			luh.Errors.Push(errors.ErrorCodeUnknown, err) | 			luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if err := luh.layerUploadResponse(w, r); err != nil { | 	if err := luh.layerUploadResponse(w, r); err != nil { | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | 		w.WriteHeader(http.StatusInternalServerError) // Error conditions here?
 | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		return | 		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) { | func (luh *layerUploadHandler) CancelLayerUpload(w http.ResponseWriter, r *http.Request) { | ||||||
| 	if luh.Upload == nil { | 	if luh.Upload == nil { | ||||||
| 		w.WriteHeader(http.StatusNotFound) | 		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) { | func (luh *layerUploadHandler) completeUpload(w http.ResponseWriter, r *http.Request, size int64, dgst digest.Digest) { | ||||||
| 	layer, err := luh.Upload.Finish(size, dgst) | 	layer, err := luh.Upload.Finish(size, dgst) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) | 		w.WriteHeader(http.StatusInternalServerError) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	layerURL, err := luh.urlBuilder.BuildBlobURL(layer.Name(), layer.Digest()) | 	layerURL, err := luh.urlBuilder.BuildBlobURL(layer.Name(), layer.Digest()) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
| 		luh.Errors.Push(errors.ErrorCodeUnknown, err) | 		luh.Errors.Push(v2.ErrorCodeUnknown, err) | ||||||
| 		w.WriteHeader(http.StatusInternalServerError) | 		w.WriteHeader(http.StatusInternalServerError) | ||||||
| 		return | 		return | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
							
								
								
									
										4
									
								
								tags.go
								
								
								
								
							
							
						
						
									
										4
									
								
								tags.go
								
								
								
								
							|  | @ -4,7 +4,7 @@ import ( | ||||||
| 	"encoding/json" | 	"encoding/json" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 
 | 
 | ||||||
| 	"github.com/docker/docker-registry/api/errors" | 	"github.com/docker/docker-registry/api/v2" | ||||||
| 	"github.com/docker/docker-registry/storage" | 	"github.com/docker/docker-registry/storage" | ||||||
| 	"github.com/gorilla/handlers" | 	"github.com/gorilla/handlers" | ||||||
| ) | ) | ||||||
|  | @ -40,7 +40,7 @@ func (th *tagsHandler) GetTags(w http.ResponseWriter, r *http.Request) { | ||||||
| 		switch err := err.(type) { | 		switch err := err.(type) { | ||||||
| 		case storage.ErrUnknownRepository: | 		case storage.ErrUnknownRepository: | ||||||
| 			w.WriteHeader(404) | 			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: | 		default: | ||||||
| 			th.Errors.PushErr(err) | 			th.Errors.PushErr(err) | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue