2014-12-12 05:08:23 +00:00
|
|
|
package urls
|
2014-11-08 00:08:14 +00:00
|
|
|
|
|
|
|
import (
|
2014-11-13 00:59:50 +00:00
|
|
|
"github.com/docker/docker-registry/common"
|
2014-11-08 00:08:14 +00:00
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
2014-12-12 05:08:23 +00:00
|
|
|
// The 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.
|
2014-11-08 00:08:14 +00:00
|
|
|
const (
|
2014-12-12 05:08:23 +00:00
|
|
|
RouteNameBase = "base"
|
|
|
|
RouteNameManifest = "manifest"
|
|
|
|
RouteNameTags = "tags"
|
|
|
|
RouteNameBlob = "blob"
|
|
|
|
RouteNameBlobUpload = "blob-upload"
|
|
|
|
RouteNameBlobUploadChunk = "blob-upload-chunk"
|
2014-11-08 00:08:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var allEndpoints = []string{
|
2014-12-12 05:08:23 +00:00
|
|
|
RouteNameManifest,
|
|
|
|
RouteNameTags,
|
|
|
|
RouteNameBlob,
|
|
|
|
RouteNameBlobUpload,
|
|
|
|
RouteNameBlobUploadChunk,
|
2014-11-08 00:08:14 +00:00
|
|
|
}
|
|
|
|
|
2014-12-12 05:08:23 +00:00
|
|
|
// Router builds a gorilla router with named routes for the various API
|
|
|
|
// methods. This can be used directly by both server implementations and
|
|
|
|
// clients.
|
|
|
|
func Router() *mux.Router {
|
2014-11-13 00:59:50 +00:00
|
|
|
router := mux.NewRouter().
|
2014-11-08 00:08:14 +00:00
|
|
|
StrictSlash(true)
|
|
|
|
|
2014-12-11 06:33:36 +00:00
|
|
|
// GET /v2/ Check Check that the registry implements API version 2(.1)
|
|
|
|
router.
|
|
|
|
Path("/v2/").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameBase)
|
2014-12-11 06:33:36 +00:00
|
|
|
|
2014-11-19 03:38:14 +00:00
|
|
|
// GET /v2/<name>/manifest/<tag> Image Manifest Fetch the image manifest identified by name and tag.
|
|
|
|
// PUT /v2/<name>/manifest/<tag> Image Manifest Upload the image manifest identified by name and tag.
|
|
|
|
// DELETE /v2/<name>/manifest/<tag> Image Manifest Delete the image identified by name and tag.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
2014-12-11 06:29:58 +00:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/manifests/{tag:" + common.TagNameRegexp.String() + "}").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameManifest)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
2014-11-13 00:59:50 +00:00
|
|
|
// GET /v2/<name>/tags/list Tags Fetch the tags under the repository identified by name.
|
|
|
|
router.
|
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/tags/list").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameTags)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
2014-11-19 03:38:14 +00:00
|
|
|
// GET /v2/<name>/blob/<digest> Layer Fetch the blob identified by digest.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
2014-12-11 06:29:58 +00:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/{digest:[a-zA-Z0-9-_+.]+:[a-zA-Z0-9-_+.=]+}").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameBlob)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
2014-11-19 03:38:14 +00:00
|
|
|
// POST /v2/<name>/blob/upload/ Layer Upload Initiate an upload of the layer identified by tarsum.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
2014-12-11 06:29:58 +00:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameBlobUpload)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
2014-11-19 03:38:14 +00:00
|
|
|
// GET /v2/<name>/blob/upload/<uuid> Layer Upload Get the status of the upload identified by tarsum and uuid.
|
|
|
|
// PUT /v2/<name>/blob/upload/<uuid> Layer Upload Upload all or a chunk of the upload identified by tarsum and uuid.
|
|
|
|
// DELETE /v2/<name>/blob/upload/<uuid> Layer Upload Cancel the upload identified by layer and uuid
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
2014-12-11 06:29:58 +00:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid}").
|
2014-12-12 05:08:23 +00:00
|
|
|
Name(RouteNameBlobUploadChunk)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
|
|
|
return router
|
|
|
|
}
|