From 09bf7522347066980c75c5b84b0836cb0c581dcf Mon Sep 17 00:00:00 2001 From: Stephen J Day Date: Wed, 11 Feb 2015 17:00:42 -0800 Subject: [PATCH] Remove Name from Layer and LayerUpload interface A Layer or LayerUpload should not be coupled with the containing repository. Remove the Name method and correctly reference from the repository where appropriate. Signed-off-by: Stephen J Day --- docs/handlers/layerupload.go | 4 ++-- docs/storage/layerreader.go | 5 ----- docs/storage/layerstore.go | 1 - docs/storage/layerupload.go | 9 ++------- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/docs/handlers/layerupload.go b/docs/handlers/layerupload.go index fa854449..63a9e776 100644 --- a/docs/handlers/layerupload.go +++ b/docs/handlers/layerupload.go @@ -215,7 +215,7 @@ func (luh *layerUploadHandler) PutLayerUploadComplete(w http.ResponseWriter, r * } // Build our canonical layer url - layerURL, err := luh.urlBuilder.BuildBlobURL(layer.Name(), layer.Digest()) + layerURL, err := luh.urlBuilder.BuildBlobURL(luh.Repository.Name(), layer.Digest()) if err != nil { luh.Errors.Push(v2.ErrorCodeUnknown, err) w.WriteHeader(http.StatusInternalServerError) @@ -268,7 +268,7 @@ func (luh *layerUploadHandler) layerUploadResponse(w http.ResponseWriter, r *htt } uploadURL, err := luh.urlBuilder.BuildBlobUploadChunkURL( - luh.Upload.Name(), luh.Upload.UUID(), + luh.Repository.Name(), luh.Upload.UUID(), url.Values{ "_state": []string{token}, }) diff --git a/docs/storage/layerreader.go b/docs/storage/layerreader.go index c539b769..2d8e588d 100644 --- a/docs/storage/layerreader.go +++ b/docs/storage/layerreader.go @@ -12,16 +12,11 @@ import ( type layerReader struct { fileReader - name string // repo name of this layer digest digest.Digest } var _ distribution.Layer = &layerReader{} -func (lrs *layerReader) Name() string { - return lrs.name -} - func (lrs *layerReader) Digest() digest.Digest { return lrs.digest } diff --git a/docs/storage/layerstore.go b/docs/storage/layerstore.go index 1769eb43..153e42a8 100644 --- a/docs/storage/layerstore.go +++ b/docs/storage/layerstore.go @@ -48,7 +48,6 @@ func (ls *layerStore) Fetch(dgst digest.Digest) (distribution.Layer, error) { return &layerReader{ fileReader: *fr, - name: ls.repository.Name(), digest: dgst, }, nil } diff --git a/docs/storage/layerupload.go b/docs/storage/layerupload.go index fe3a0721..369a9bd5 100644 --- a/docs/storage/layerupload.go +++ b/docs/storage/layerupload.go @@ -27,11 +27,6 @@ type layerUploadController struct { var _ distribution.LayerUpload = &layerUploadController{} -// Name of the repository under which the layer will be linked. -func (luc *layerUploadController) Name() string { - return luc.layerStore.repository.Name() -} - // UUID returns the identifier for this upload. func (luc *layerUploadController) UUID() string { return luc.uuid @@ -194,7 +189,7 @@ func (luc *layerUploadController) moveLayer(dgst digest.Digest) error { // named repository for the upload controller. func (luc *layerUploadController) linkLayer(digest digest.Digest) error { layerLinkPath, err := luc.layerStore.repository.registry.pm.path(layerLinkPathSpec{ - name: luc.Name(), + name: luc.layerStore.repository.Name(), digest: digest, }) @@ -210,7 +205,7 @@ func (luc *layerUploadController) linkLayer(digest digest.Digest) error { // resources are already not present, no error will be returned. func (luc *layerUploadController) removeResources() error { dataPath, err := luc.layerStore.repository.registry.pm.path(uploadDataPathSpec{ - name: luc.Name(), + name: luc.layerStore.repository.Name(), uuid: luc.uuid, })