{"modulePath":"github.com/AlaudaDevops/distribution","version":"v2.0.0-alpha.2+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package v2\n\nPackage v2 describes routes, urls and the error codes used in the Docker Registry JSON HTTP API V2. In addition to declarations, descriptors are provided for routes and error codes that can be used for implementation and automatically generating documentation.\n\nDefinitions here are considered to be locked down for the V2 registry api. Any changes must be considered carefully and should not proceed without a change proposal in docker core.\n\n## Constants\n\n```go\nconst (\n\t// RepositoryNameComponentMinLength is the minimum number of characters in a\n\t// single repository name slash-delimited component\n\tRepositoryNameComponentMinLength = 2\n\n\t// RepositoryNameComponentMaxLength is the maximum number of characters in a\n\t// single repository name slash-delimited component\n\tRepositoryNameComponentMaxLength = 30\n\n\t// RepositoryNameMinComponents is the minimum number of slash-delimited\n\t// components that a repository name must have\n\tRepositoryNameMinComponents = 1\n\n\t// RepositoryNameMaxComponents is the maximum number of slash-delimited\n\t// components that a repository name must have\n\tRepositoryNameMaxComponents = 5\n\n\t// RepositoryNameTotalLengthMax is the maximum total number of characters in\n\t// a repository name\n\tRepositoryNameTotalLengthMax = 255\n)\n```\n\n```go\nconst (\n\tRouteNameBase            = \"base\"\n\tRouteNameManifest        = \"manifest\"\n\tRouteNameTags            = \"tags\"\n\tRouteNameBlob            = \"blob\"\n\tRouteNameBlobUpload      = \"blob-upload\"\n\tRouteNameBlobUploadChunk = \"blob-upload-chunk\"\n)\n```\nThe following are definitions of the name under which all V2 routes are registered. These symbols can be used to look up a route based on the name.\n\n## Variables\n\n```go\nvar (\n\t// ErrRepositoryNameComponentShort is returned when a repository name\n\t// contains a component which is shorter than\n\t// RepositoryNameComponentMinLength\n\tErrRepositoryNameComponentShort = fmt.Errorf(\"respository name component must be %v or more characters\", RepositoryNameComponentMinLength)\n\n\t// ErrRepositoryNameComponentLong is returned when a repository name\n\t// contains a component which is longer than\n\t// RepositoryNameComponentMaxLength\n\tErrRepositoryNameComponentLong = fmt.Errorf(\"respository name component must be %v characters or less\", RepositoryNameComponentMaxLength)\n\n\t// ErrRepositoryNameMissingComponents is returned when a repository name\n\t// contains fewer than RepositoryNameMinComponents components\n\tErrRepositoryNameMissingComponents = fmt.Errorf(\"repository name must have at least %v components\", RepositoryNameMinComponents)\n\n\t// ErrRepositoryNameTooManyComponents is returned when a repository name\n\t// contains more than RepositoryNameMaxComponents components\n\tErrRepositoryNameTooManyComponents = fmt.Errorf(\"repository name %v or less components\", RepositoryNameMaxComponents)\n\n\t// ErrRepositoryNameLong is returned when a repository name is longer than\n\t// RepositoryNameTotalLengthMax\n\tErrRepositoryNameLong = fmt.Errorf(\"repository name must not be more than %v characters\", RepositoryNameTotalLengthMax)\n\n\t// ErrRepositoryNameComponentInvalid is returned when a repository name does\n\t// not match RepositoryNameComponentRegexp\n\tErrRepositoryNameComponentInvalid = fmt.Errorf(\"repository name component must match %q\", RepositoryNameComponentRegexp.String())\n)\n```\n\n```go\nvar APIDescriptor = struct {\n\t// RouteDescriptors provides a list of the routes available in the API.\n\tRouteDescriptors []RouteDescriptor\n\n\t// ErrorDescriptors provides a list of the error codes and their\n\t// associated documentation and metadata.\n\tErrorDescriptors []ErrorDescriptor\n}{\n\tRouteDescriptors: routeDescriptors,\n\tErrorDescriptors: errorDescriptors,\n}\n```\nAPIDescriptor exports descriptions of the layout of the v2 registry API.\n\n```go\nvar RepositoryNameComponentAnchoredRegexp = regexp.MustCompile(`^` + RepositoryNameComponentRegexp.String() + `$`)\n```\nRepositoryNameComponentAnchoredRegexp is the version of RepositoryNameComponentRegexp which must completely match the content\n\n```go\nvar RepositoryNameComponentRegexp = regexp.MustCompile(`[a-z0-9]+(?:[._-][a-z0-9]+)*`)\n```\nRepositoryNameComponentRegexp restricts registtry path components names to start with at least two letters or numbers, with following parts able to separated by one period, dash or underscore.\n\n```go\nvar RepositoryNameRegexp = regexp.MustCompile(`(?:` + RepositoryNameComponentRegexp.String() + `/){0,4}` + RepositoryNameComponentRegexp.String())\n```\nRepositoryNameRegexp builds on RepositoryNameComponentRegexp to allow 1 to 5 path components, separated by a forward slash.\n\n```go\nvar TagNameRegexp = regexp.MustCompile(`[\\w][\\w.-]{0,127}`)\n```\nTagNameRegexp matches valid tag names. From docker/docker:graph/tags.go.\n\n## Functions\n\n```go\nfunc Router() *mux.Router\n```\nRouter builds a gorilla router with named routes for the various API methods. This can be used directly by both server implementations and clients.\n\n```go\nfunc ValidateRespositoryName(name string) error\n```\nValidateRespositoryName ensures the repository name is valid for use in the registry. This function accepts a superset of what might be accepted by docker core or docker hub. If the name does not pass validation, an error, describing the conditions, is returned.\n\n## Types\n\n```go\ntype BodyDescriptor struct {\n\tContentType string\n\tFormat      string\n}\n```\nBodyDescriptor describes a request body and its expected content type. For the most  part, it should be example json or some placeholder for body data in documentation.\n\n```go\ntype Error struct {\n\tCode    ErrorCode   `json:\"code\"`\n\tMessage string      `json:\"message,omitempty\"`\n\tDetail  interface{} `json:\"detail,omitempty\"`\n}\n```\nError provides a wrapper around ErrorCode with extra Details provided.\n\n```go\nfunc (e Error) Error() string\n```\nError returns a human readable representation of the error.\n\n```go\ntype ErrorCode int\n```\nErrorCode represents the error type. The errors are serialized via strings and the integer format may change and should \\*never\\* be exported.\n\n```go\nconst (\n\t// ErrorCodeUnknown is a catch-all for errors not defined below.\n\tErrorCodeUnknown ErrorCode = iota\n\n\t// ErrorCodeUnauthorized is returned if a request is not authorized.\n\tErrorCodeUnauthorized\n\n\t// ErrorCodeDigestInvalid is returned when uploading a blob if the\n\t// provided digest does not match the blob contents.\n\tErrorCodeDigestInvalid\n\n\t// ErrorCodeSizeInvalid is returned when uploading a blob if the provided\n\t// size does not match the content length.\n\tErrorCodeSizeInvalid\n\n\t// ErrorCodeNameInvalid is returned when the name in the manifest does not\n\t// match the provided name.\n\tErrorCodeNameInvalid\n\n\t// ErrorCodeTagInvalid is returned when the tag in the manifest does not\n\t// match the provided tag.\n\tErrorCodeTagInvalid\n\n\t// ErrorCodeNameUnknown when the repository name is not known.\n\tErrorCodeNameUnknown\n\n\t// ErrorCodeManifestUnknown returned when image manifest is unknown.\n\tErrorCodeManifestUnknown\n\n\t// ErrorCodeManifestInvalid returned when an image manifest is invalid,\n\t// typically during a PUT operation. This error encompasses all errors\n\t// encountered during manifest validation that aren't signature errors.\n\tErrorCodeManifestInvalid\n\n\t// ErrorCodeManifestUnverified is returned when the manifest fails\n\t// signature verfication.\n\tErrorCodeManifestUnverified\n\n\t// ErrorCodeBlobUnknown is returned when a blob is unknown to the\n\t// registry. This can happen when the manifest references a nonexistent\n\t// layer or the result is not found by a blob fetch.\n\tErrorCodeBlobUnknown\n\n\t// ErrorCodeBlobUploadUnknown is returned when an upload is unknown.\n\tErrorCodeBlobUploadUnknown\n\n\t// ErrorCodeBlobUploadInvalid is returned when an upload is invalid.\n\tErrorCodeBlobUploadInvalid\n)\n```\n\n```go\nfunc ParseErrorCode(s string) ErrorCode\n```\nParseErrorCode attempts to parse the error code string, returning ErrorCodeUnknown if the error is not known.\n\n```go\nfunc (ec ErrorCode) Descriptor() ErrorDescriptor\n```\nDescriptor returns the descriptor for the error code.\n\n```go\nfunc (ec ErrorCode) MarshalText() (text []byte, err error)\n```\nMarshalText encodes the receiver into UTF-8-encoded text and returns the result.\n\n```go\nfunc (ec ErrorCode) Message() string\n```\nMessage returned the human-readable error message for this error code.\n\n```go\nfunc (ec ErrorCode) String() string\n```\nString returns the canonical identifier for this error code.\n\n```go\nfunc (ec *ErrorCode) UnmarshalText(text []byte) error\n```\nUnmarshalText decodes the form generated by MarshalText.\n\n```go\ntype ErrorDescriptor struct {\n\t// Code is the error code that this descriptor describes.\n\tCode ErrorCode\n\n\t// Value provides a unique, string key, often captilized with\n\t// underscores, to identify the error code. This value is used as the\n\t// keyed value when serializing api errors.\n\tValue string\n\n\t// Message is a short, human readable decription of the error condition\n\t// included in API responses.\n\tMessage string\n\n\t// Description provides a complete account of the errors purpose, suitable\n\t// for use in documentation.\n\tDescription string\n\n\t// HTTPStatusCodes provides a list of status under which this error\n\t// condition may arise. If it is empty, the error condition may be seen\n\t// for any status code.\n\tHTTPStatusCodes []int\n}\n```\nErrorDescriptor provides relevant information about a given error code.\n\n```go\ntype Errors struct {\n\tErrors []Error `json:\"errors,omitempty\"`\n}\n```\nErrors provides the envelope for multiple errors and a few sugar methods for use within the application.\n\n```go\nfunc (errs *Errors) Clear()\n```\nClear clears the errors.\n\n```go\nfunc (errs *Errors) Error() string\n```\n\n```go\nfunc (errs *Errors) Len() int\n```\nLen returns the current number of errors.\n\n```go\nfunc (errs *Errors) Push(code ErrorCode, details ...interface{})\n```\nPush pushes an error on to the error stack, with the optional detail argument. It is a programming error (ie panic) to push more than one detail at a time.\n\n```go\nfunc (errs *Errors) PushErr(err error)\n```\nPushErr pushes an error interface onto the error stack.\n\n```go\ntype MethodDescriptor struct {\n\n\t// Method is an HTTP method, such as GET, PUT or POST.\n\tMethod string\n\n\t// Description should provide an overview of the functionality provided by\n\t// the covered method, suitable for use in documentation. Use of markdown\n\t// here is encouraged.\n\tDescription string\n\n\t// Requests is a slice of request descriptors enumerating how this\n\t// endpoint may be used.\n\tRequests []RequestDescriptor\n}\n```\nMethodDescriptor provides a description of the requests that may be conducted with the target method.\n\n```go\ntype ParameterDescriptor struct {\n\t// Name is the name of the parameter, either of the path component or\n\t// query parameter.\n\tName string\n\n\t// Type specifies the type of the parameter, such as string, integer, etc.\n\tType string\n\n\t// Description provides a human-readable description of the parameter.\n\tDescription string\n\n\t// Required means the field is required when set.\n\tRequired bool\n\n\t// Format is a specifying the string format accepted by this parameter.\n\tFormat string\n\n\t// Regexp is a compiled regular expression that can be used to validate\n\t// the contents of the parameter.\n\tRegexp *regexp.Regexp\n\n\t// Examples provides multiple examples for the values that might be valid\n\t// for this parameter.\n\tExamples []string\n}\n```\nParameterDescriptor describes the format of a request parameter, which may be a header, path parameter or query parameter.\n\n```go\ntype RequestDescriptor struct {\n\t// Name provides a short identifier for the request, usable as a title or\n\t// to provide quick context for the particalar request.\n\tName string\n\n\t// Description should cover the requests purpose, covering any details for\n\t// this particular use case.\n\tDescription string\n\n\t// Headers describes headers that must be used with the HTTP request.\n\tHeaders []ParameterDescriptor\n\n\t// PathParameters enumerate the parameterized path components for the\n\t// given request, as defined in the route's regular expression.\n\tPathParameters []ParameterDescriptor\n\n\t// QueryParameters provides a list of query parameters for the given\n\t// request.\n\tQueryParameters []ParameterDescriptor\n\n\t// Body describes the format of the request body.\n\tBody BodyDescriptor\n\n\t// Successes enumerates the possible responses that are considered to be\n\t// the result of a successful request.\n\tSuccesses []ResponseDescriptor\n\n\t// Failures covers the possible failures from this particular request.\n\tFailures []ResponseDescriptor\n}\n```\nRequestDescriptor covers a particular set of headers and parameters that can be carried out with the parent method. Its most helpful to have one RequestDescriptor per API use case.\n\n```go\ntype ResponseDescriptor struct {\n\t// Name provides a short identifier for the response, usable as a title or\n\t// to provide quick context for the particalar response.\n\tName string\n\n\t// Description should provide a brief overview of the role of the\n\t// response.\n\tDescription string\n\n\t// StatusCode specifies the status recieved by this particular response.\n\tStatusCode int\n\n\t// Headers covers any headers that may be returned from the response.\n\tHeaders []ParameterDescriptor\n\n\t// ErrorCodes enumerates the error codes that may be returned along with\n\t// the response.\n\tErrorCodes []ErrorCode\n\n\t// Body describes the body of the response, if any.\n\tBody BodyDescriptor\n}\n```\nResponseDescriptor describes the components of an API response.\n\n```go\ntype RouteDescriptor struct {\n\t// Name is the name of the route, as specified in RouteNameXXX exports.\n\t// These names a should be considered a unique reference for a route. If\n\t// the route is registered with gorilla, this is the name that will be\n\t// used.\n\tName string\n\n\t// Path is a gorilla/mux-compatible regexp that can be used to match the\n\t// route. For any incoming method and path, only one route descriptor\n\t// should match.\n\tPath string\n\n\t// Entity should be a short, human-readalbe description of the object\n\t// targeted by the endpoint.\n\tEntity string\n\n\t// Description should provide an accurate overview of the functionality\n\t// provided by the route.\n\tDescription string\n\n\t// Methods should describe the various HTTP methods that may be used on\n\t// this route, including request and response formats.\n\tMethods []MethodDescriptor\n}\n```\nRouteDescriptor describes a route specified by name.\n\n```go\ntype URLBuilder struct {\n\t// contains filtered or unexported fields\n}\n```\nURLBuilder creates registry API urls from a single base endpoint. It can be used to create urls for use in a registry client or server.\n\nAll urls will be created from the given base, including the api version. For example, if a root of \"/foo/\" is provided, urls generated will be fall under \"/foo/v2/...\". Most application will only provide a schema, host and port, such as \"[https://localhost:5000/](https://localhost:5000/)\".\n\n```go\nfunc NewURLBuilder(root *url.URL) *URLBuilder\n```\nNewURLBuilder creates a URLBuilder with provided root url object.\n\n```go\nfunc NewURLBuilderFromRequest(r *http.Request) *URLBuilder\n```\nNewURLBuilderFromRequest uses information from an \\*http.Request to construct the root url.\n\n```go\nfunc NewURLBuilderFromString(root string) (*URLBuilder, error)\n```\nNewURLBuilderFromString workes identically to NewURLBuilder except it takes a string argument for the root, returning an error if it is not a valid url.\n\n```go\nfunc (ub *URLBuilder) BuildBaseURL() (string, error)\n```\nBuildBaseURL constructs a base url for the API, typically just \"/v2/\".\n\n```go\nfunc (ub *URLBuilder) BuildBlobURL(name string, dgst digest.Digest) (string, error)\n```\nBuildBlobURL constructs the url for the blob identified by name and dgst.\n\n```go\nfunc (ub *URLBuilder) BuildBlobUploadChunkURL(name, uuid string, values ...url.Values) (string, error)\n```\nBuildBlobUploadChunkURL constructs a url for the upload identified by uuid, including any url values. This should generally not be used by clients, as this url is provided by server implementations during the blob upload process.\n\n```go\nfunc (ub *URLBuilder) BuildBlobUploadURL(name string, values ...url.Values) (string, error)\n```\nBuildBlobUploadURL constructs a url to begin a blob upload in the repository identified by name.\n\n```go\nfunc (ub *URLBuilder) BuildManifestURL(name, tag string) (string, error)\n```\nBuildManifestURL constructs a url for the manifest identified by name and tag.\n\n```go\nfunc (ub *URLBuilder) BuildTagsURL(name string) (string, error)\n```\nBuildTagsURL constructs a url to list the tags in the named repository.\n\n","path":"github.com/AlaudaDevops/distribution/api/v2","name":"v2","synopsis":"Package v2 describes routes, urls and the error codes used in the Docker Registry JSON HTTP API V2.","isRedistributable":true}
