From 286a6449487e9131949d2e766ba99716d94eff71 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 --- layer.go | 6 ------ registry/handlers/layerupload.go | 4 ++-- registry/storage/layerreader.go | 5 ----- registry/storage/layerstore.go | 1 - registry/storage/layerupload.go | 9 ++------- 5 files changed, 4 insertions(+), 21 deletions(-) diff --git a/layer.go b/layer.go index 129a5f76f..dedc0538a 100644 --- a/layer.go +++ b/layer.go @@ -17,9 +17,6 @@ type Layer interface { io.ReadSeeker io.Closer - // Name returns the repository under which this layer is linked. - Name() string // TODO(stevvooe): struggling with nomenclature: should this be "repo" or "name"? - // Digest returns the unique digest of the blob, which is the tarsum for // layers. Digest() digest.Digest @@ -36,9 +33,6 @@ type LayerUpload interface { io.ReaderFrom io.Closer - // Name of the repository under which the layer will be linked. - Name() string - // UUID returns the identifier for this upload. UUID() string diff --git a/registry/handlers/layerupload.go b/registry/handlers/layerupload.go index fa854449a..63a9e776b 100644 --- a/registry/handlers/layerupload.go +++ b/registry/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/registry/storage/layerreader.go b/registry/storage/layerreader.go index c539b7696..2d8e588d4 100644 --- a/registry/storage/layerreader.go +++ b/registry/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/registry/storage/layerstore.go b/registry/storage/layerstore.go index 1769eb43a..153e42a89 100644 --- a/registry/storage/layerstore.go +++ b/registry/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/registry/storage/layerupload.go b/registry/storage/layerupload.go index fe3a0721f..369a9bd5e 100644 --- a/registry/storage/layerupload.go +++ b/registry/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, })