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-11-11 02:26:06 +00:00
|
|
|
routeNameImageManifest = "image-manifest"
|
|
|
|
routeNameTags = "tags"
|
|
|
|
routeNameLayer = "layer"
|
|
|
|
routeNameLayerUpload = "layer-upload"
|
|
|
|
routeNameLayerUploadResume = "layer-upload-resume"
|
2014-11-08 00:08:14 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var allEndpoints = []string{
|
|
|
|
routeNameImageManifest,
|
|
|
|
routeNameTags,
|
|
|
|
routeNameLayer,
|
|
|
|
routeNameLayerUpload,
|
2014-11-11 02:26:06 +00:00
|
|
|
routeNameLayerUploadResume,
|
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)
|
|
|
|
|
|
|
|
// GET /v2/<name>/image/<tag> Image Manifest Fetch the image manifest identified by name and tag.
|
|
|
|
// PUT /v2/<name>/image/<tag> Image Manifest Upload the image manifest identified by name and tag.
|
|
|
|
// DELETE /v2/<name>/image/<tag> Image Manifest Delete the image identified by name and tag.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/image/{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)
|
|
|
|
|
|
|
|
// GET /v2/<name>/layer/<tarsum> Layer Fetch the layer identified by tarsum.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/layer/{tarsum:" + common.TarsumRegexp.String() + "}").
|
2014-11-08 00:08:14 +00:00
|
|
|
Name(routeNameLayer)
|
|
|
|
|
|
|
|
// POST /v2/<name>/layer/<tarsum>/upload/ Layer Upload Initiate an upload of the layer identified by tarsum. Requires length and a checksum parameter.
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/layer/{tarsum:" + common.TarsumRegexp.String() + "}/upload/").
|
2014-11-11 02:26:06 +00:00
|
|
|
Name(routeNameLayerUpload)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
|
|
|
// GET /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Get the status of the upload identified by tarsum and uuid.
|
|
|
|
// PUT /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Upload all or a chunk of the upload identified by tarsum and uuid.
|
|
|
|
// DELETE /v2/<name>/layer/<tarsum>/upload/<uuid> Layer Upload Cancel the upload identified by layer and uuid
|
2014-11-13 00:59:50 +00:00
|
|
|
router.
|
|
|
|
Path("/v2/{name:" + common.RepositoryNameRegexp.String() + "}/layer/{tarsum:" + common.TarsumRegexp.String() + "}/upload/{uuid}").
|
2014-11-11 02:26:06 +00:00
|
|
|
Name(routeNameLayerUploadResume)
|
2014-11-08 00:08:14 +00:00
|
|
|
|
|
|
|
return router
|
|
|
|
}
|