2014-11-08 00:08:14 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2014-12-11 06:33:36 +00:00
|
|
|
routeNameBase = "base"
|
2014-11-19 03:38:14 +00:00
|
|
|
routeNameImageManifest = "image-manifest"
|
|
|
|
routeNameTags = "tags"
|
|
|
|
routeNameBlob = "blob"
|
|
|
|
routeNameBlobUpload = "blob-upload"
|
|
|
|
routeNameBlobUploadResume = "blob-upload-resume"
|
2014-11-08 00:08:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var allEndpoints = []string{
|
|
|
|
routeNameImageManifest,
|
|
|
|
routeNameTags,
|
2014-11-19 03:38:14 +00:00
|
|
|
routeNameBlob,
|
|
|
|
routeNameBlobUpload,
|
|
|
|
routeNameBlobUploadResume,
|
2014-11-08 00:08:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// v2APIRouter builds a gorilla router with named routes for the various API
|
|
|
|
// methods. We may export this for use by the client.
|
|
|
|
func v2APIRouter() *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/").
|
|
|
|
Name(routeNameBase)
|
|
|
|
|
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-11-08 00:08:14 +00:00
|
|
|
Name(routeNameImageManifest)
|
|
|
|
|
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-11-08 00:08:14 +00:00
|
|
|
Name(routeNameTags)
|
|
|
|
|
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-11-19 03:38:14 +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-11-19 03:38:14 +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-11-19 03:38:14 +00:00
|
|
|
Name(routeNameBlobUploadResume)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
|
|
|
return router
|
|
|
|
}
|