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 <stephen.day@docker.com>
This commit is contained in:
Stephen J Day 2015-02-11 17:00:42 -08:00
parent 27b03f2136
commit 286a644948
5 changed files with 4 additions and 21 deletions

View File

@ -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

View File

@ -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},
})

View File

@ -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
}

View File

@ -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
}

View File

@ -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,
})