2014-11-08 01:08:14 +01:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
2014-11-13 01:59:50 +01:00
|
|
|
"github.com/docker/docker-registry/common"
|
2014-11-08 01:08:14 +01:00
|
|
|
"github.com/gorilla/mux"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2014-12-11 07:33:36 +01:00
|
|
|
routeNameBase = "base"
|
2014-11-19 04:38:14 +01:00
|
|
|
routeNameImageManifest = "image-manifest"
|
|
|
|
routeNameTags = "tags"
|
|
|
|
routeNameBlob = "blob"
|
|
|
|
routeNameBlobUpload = "blob-upload"
|
|
|
|
routeNameBlobUploadResume = "blob-upload-resume"
|
2014-11-08 01:08:14 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
var allEndpoints = []string{
|
|
|
|
routeNameImageManifest,
|
|
|
|
routeNameTags,
|
2014-11-19 04:38:14 +01:00
|
|
|
routeNameBlob,
|
|
|
|
routeNameBlobUpload,
|
|
|
|
routeNameBlobUploadResume,
|
2014-11-08 01:08:14 +01: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 01:59:50 +01:00
|
|
|
router := mux.NewRouter().
|
2014-11-08 01:08:14 +01:00
|
|
|
StrictSlash(true)
|
|
|
|
|
2014-12-11 07:33:36 +01:00
|
|
|
// GET /v2/ Check Check that the registry implements API version 2(.1)
|
|
|
|
router.
|
|
|
|
Path("/v2/").
|
|
|
|
Name(routeNameBase)
|
|
|
|
|
2014-11-19 04:38:14 +01: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 01:59:50 +01:00
|
|
|
router.
|
2014-12-11 07:29:58 +01:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/manifests/{tag:" + common.TagNameRegexp.String() + "}").
|
2014-11-08 01:08:14 +01:00
|
|
|
Name(routeNameImageManifest)
|
|
|
|
|
2014-11-13 01:59:50 +01: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 01:08:14 +01:00
|
|
|
Name(routeNameTags)
|
|
|
|
|
2014-11-19 04:38:14 +01:00
|
|
|
// GET /v2/<name>/blob/<digest> Layer Fetch the blob identified by digest.
|
2014-11-13 01:59:50 +01:00
|
|
|
router.
|
2014-12-11 07:29:58 +01:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/{digest:[a-zA-Z0-9-_+.]+:[a-zA-Z0-9-_+.=]+}").
|
2014-11-19 04:38:14 +01:00
|
|
|
Name(routeNameBlob)
|
2014-11-08 01:08:14 +01:00
|
|
|
|
2014-11-19 04:38:14 +01:00
|
|
|
// POST /v2/<name>/blob/upload/ Layer Upload Initiate an upload of the layer identified by tarsum.
|
2014-11-13 01:59:50 +01:00
|
|
|
router.
|
2014-12-11 07:29:58 +01:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/").
|
2014-11-19 04:38:14 +01:00
|
|
|
Name(routeNameBlobUpload)
|
2014-11-08 01:08:14 +01:00
|
|
|
|
2014-11-19 04:38:14 +01: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 01:59:50 +01:00
|
|
|
router.
|
2014-12-11 07:29:58 +01:00
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/blobs/uploads/{uuid}").
|
2014-11-19 04:38:14 +01:00
|
|
|
Name(routeNameBlobUploadResume)
|
2014-11-08 01:08:14 +01:00
|
|
|
|
|
|
|
return router
|
|
|
|
}
|