7b56d10076
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.
32 lines
960 B
Go
32 lines
960 B
Go
package registry
|
|
|
|
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
|
|
// be on this object.
|
|
type Context struct {
|
|
// App points to the application structure that created this context.
|
|
*App
|
|
|
|
// Name is the prefix for the current request. Corresponds to the
|
|
// namespace/repository associated with the image.
|
|
Name string
|
|
|
|
// 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
|
|
|
|
// vars contains the extracted gorilla/mux variables that can be used for
|
|
// assignment.
|
|
vars map[string]string
|
|
|
|
// log provides a context specific logger.
|
|
log *logrus.Entry
|
|
|
|
urlBuilder *urlBuilder
|
|
}
|