Lock down HTTP API error codes

This commit locks down the set of http error codes that will be part of the
inital V2 specification, proposed in docker/docker#9015. The naming order has
been slightly changed and there are few tweaks to ensure all conditions are
captured but this will be set the docker core will be impleemnted against.

To support this, the errors have been moved into an api/errors package. A new
type, ErrorDescriptor, has been defined to centralize the code, message and
definitions used with each type. The information therein can be used to
generate documentation and response code mappings (yet to come...).

In addition to the refactoring that came along with this change, several tests
have been added to ensure serialization round trips are reliable. This allows
better support for using these error types on the client and server side. This
is coupled with some tweaks in the client code to fix issues with error
reporting.

Other fixes in the client include moving client-specific errors out of the base
package and ensuring that we have correct parameters for finishing uploads.
This commit is contained in:
Stephen J Day 2014-12-09 21:25:54 -08:00
parent 33d89b4bca
commit 7b56d10076
14 changed files with 716 additions and 514 deletions

View file

@ -1,6 +1,9 @@
package registry
import "github.com/Sirupsen/logrus"
import (
"github.com/Sirupsen/logrus"
"github.com/docker/docker-registry/api/errors"
)
// Context should contain the request specific context for use in across
// handlers. Resources that don't need to be shared across handlers should not
@ -16,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.Errors
// vars contains the extracted gorilla/mux variables that can be used for
// assignment.