registy/handlers: move images to manifests

Once upon a time, we referred to manifests and images interchangably.
That simple past is no more. As we grow, we update our nomenclature and
so follows our code.

Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2017-01-10 15:16:45 -08:00
parent ff68ca391b
commit c91a68ca05
No known key found for this signature in database
GPG key ID: FB5F6B2905D7ECF3
2 changed files with 21 additions and 21 deletions

View file

@ -100,7 +100,7 @@ func NewApp(ctx context.Context, config *configuration.Configuration) *App {
app.register(v2.RouteNameBase, func(ctx *Context, r *http.Request) http.Handler { app.register(v2.RouteNameBase, func(ctx *Context, r *http.Request) http.Handler {
return http.HandlerFunc(apiBase) return http.HandlerFunc(apiBase)
}) })
app.register(v2.RouteNameManifest, imageManifestDispatcher) app.register(v2.RouteNameManifest, manifestDispatcher)
app.register(v2.RouteNameCatalog, catalogDispatcher) app.register(v2.RouteNameCatalog, catalogDispatcher)
app.register(v2.RouteNameTags, tagsDispatcher) app.register(v2.RouteNameTags, tagsDispatcher)
app.register(v2.RouteNameBlob, blobDispatcher) app.register(v2.RouteNameBlob, blobDispatcher)

View file

@ -26,36 +26,36 @@ const (
defaultOS = "linux" defaultOS = "linux"
) )
// imageManifestDispatcher takes the request context and builds the // manifestDispatcher takes the request context and builds the
// appropriate handler for handling image manifest requests. // appropriate handler for handling manifest requests.
func imageManifestDispatcher(ctx *Context, r *http.Request) http.Handler { func manifestDispatcher(ctx *Context, r *http.Request) http.Handler {
imageManifestHandler := &imageManifestHandler{ manifestHandler := &manifestHandler{
Context: ctx, Context: ctx,
} }
reference := getReference(ctx) reference := getReference(ctx)
dgst, err := digest.Parse(reference) dgst, err := digest.Parse(reference)
if err != nil { if err != nil {
// We just have a tag // We just have a tag
imageManifestHandler.Tag = reference manifestHandler.Tag = reference
} else { } else {
imageManifestHandler.Digest = dgst manifestHandler.Digest = dgst
} }
mhandler := handlers.MethodHandler{ mhandler := handlers.MethodHandler{
"GET": http.HandlerFunc(imageManifestHandler.GetImageManifest), "GET": http.HandlerFunc(manifestHandler.GetManifest),
"HEAD": http.HandlerFunc(imageManifestHandler.GetImageManifest), "HEAD": http.HandlerFunc(manifestHandler.GetManifest),
} }
if !ctx.readOnly { if !ctx.readOnly {
mhandler["PUT"] = http.HandlerFunc(imageManifestHandler.PutImageManifest) mhandler["PUT"] = http.HandlerFunc(manifestHandler.PutManifest)
mhandler["DELETE"] = http.HandlerFunc(imageManifestHandler.DeleteImageManifest) mhandler["DELETE"] = http.HandlerFunc(manifestHandler.DeleteManifest)
} }
return mhandler return mhandler
} }
// imageManifestHandler handles http operations on image manifests. // manifestHandler handles http operations on image manifests.
type imageManifestHandler struct { type manifestHandler struct {
*Context *Context
// One of tag or digest gets set, depending on what is present in context. // One of tag or digest gets set, depending on what is present in context.
@ -63,8 +63,8 @@ type imageManifestHandler struct {
Digest digest.Digest Digest digest.Digest
} }
// GetImageManifest fetches the image manifest from the storage backend, if it exists. // GetManifest fetches the image manifest from the storage backend, if it exists.
func (imh *imageManifestHandler) GetImageManifest(w http.ResponseWriter, r *http.Request) { func (imh *manifestHandler) GetManifest(w http.ResponseWriter, r *http.Request) {
ctxu.GetLogger(imh).Debug("GetImageManifest") ctxu.GetLogger(imh).Debug("GetImageManifest")
manifests, err := imh.Repository.Manifests(imh) manifests, err := imh.Repository.Manifests(imh)
if err != nil { if err != nil {
@ -186,7 +186,7 @@ func (imh *imageManifestHandler) GetImageManifest(w http.ResponseWriter, r *http
w.Write(p) w.Write(p)
} }
func (imh *imageManifestHandler) convertSchema2Manifest(schema2Manifest *schema2.DeserializedManifest) (distribution.Manifest, error) { func (imh *manifestHandler) convertSchema2Manifest(schema2Manifest *schema2.DeserializedManifest) (distribution.Manifest, error) {
targetDescriptor := schema2Manifest.Target() targetDescriptor := schema2Manifest.Target()
blobs := imh.Repository.Blobs(imh) blobs := imh.Repository.Blobs(imh)
configJSON, err := blobs.Get(imh, targetDescriptor.Digest) configJSON, err := blobs.Get(imh, targetDescriptor.Digest)
@ -231,8 +231,8 @@ func etagMatch(r *http.Request, etag string) bool {
return false return false
} }
// PutImageManifest validates and stores an image in the registry. // PutManifest validates and stores a manifest in the registry.
func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http.Request) { func (imh *manifestHandler) PutManifest(w http.ResponseWriter, r *http.Request) {
ctxu.GetLogger(imh).Debug("PutImageManifest") ctxu.GetLogger(imh).Debug("PutImageManifest")
manifests, err := imh.Repository.Manifests(imh) manifests, err := imh.Repository.Manifests(imh)
if err != nil { if err != nil {
@ -348,7 +348,7 @@ func (imh *imageManifestHandler) PutImageManifest(w http.ResponseWriter, r *http
// applyResourcePolicy checks whether the resource class matches what has // applyResourcePolicy checks whether the resource class matches what has
// been authorized and allowed by the policy configuration. // been authorized and allowed by the policy configuration.
func (imh *imageManifestHandler) applyResourcePolicy(manifest distribution.Manifest) error { func (imh *manifestHandler) applyResourcePolicy(manifest distribution.Manifest) error {
allowedClasses := imh.App.Config.Policy.Repository.Classes allowedClasses := imh.App.Config.Policy.Repository.Classes
if len(allowedClasses) == 0 { if len(allowedClasses) == 0 {
return nil return nil
@ -413,8 +413,8 @@ func (imh *imageManifestHandler) applyResourcePolicy(manifest distribution.Manif
} }
// DeleteImageManifest removes the manifest with the given digest from the registry. // DeleteManifest removes the manifest with the given digest from the registry.
func (imh *imageManifestHandler) DeleteImageManifest(w http.ResponseWriter, r *http.Request) { func (imh *manifestHandler) DeleteManifest(w http.ResponseWriter, r *http.Request) {
ctxu.GetLogger(imh).Debug("DeleteImageManifest") ctxu.GetLogger(imh).Debug("DeleteImageManifest")
manifests, err := imh.Repository.Manifests(imh) manifests, err := imh.Repository.Manifests(imh)