1
0
mirror of https://github.com/distribution/distribution synced 2024-11-06 19:35:52 +01:00

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

@ -17,9 +17,6 @@ type Layer interface {
io.ReadSeeker io.ReadSeeker
io.Closer 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 // Digest returns the unique digest of the blob, which is the tarsum for
// layers. // layers.
Digest() digest.Digest Digest() digest.Digest
@ -36,9 +33,6 @@ type LayerUpload interface {
io.ReaderFrom io.ReaderFrom
io.Closer io.Closer
// Name of the repository under which the layer will be linked.
Name() string
// UUID returns the identifier for this upload. // UUID returns the identifier for this upload.
UUID() string UUID() string

@ -215,7 +215,7 @@ func (luh *layerUploadHandler) PutLayerUploadComplete(w http.ResponseWriter, r *
} }
// Build our canonical layer url // 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 { if err != nil {
luh.Errors.Push(v2.ErrorCodeUnknown, err) luh.Errors.Push(v2.ErrorCodeUnknown, err)
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
@ -268,7 +268,7 @@ func (luh *layerUploadHandler) layerUploadResponse(w http.ResponseWriter, r *htt
} }
uploadURL, err := luh.urlBuilder.BuildBlobUploadChunkURL( uploadURL, err := luh.urlBuilder.BuildBlobUploadChunkURL(
luh.Upload.Name(), luh.Upload.UUID(), luh.Repository.Name(), luh.Upload.UUID(),
url.Values{ url.Values{
"_state": []string{token}, "_state": []string{token},
}) })

@ -12,16 +12,11 @@ import (
type layerReader struct { type layerReader struct {
fileReader fileReader
name string // repo name of this layer
digest digest.Digest digest digest.Digest
} }
var _ distribution.Layer = &layerReader{} var _ distribution.Layer = &layerReader{}
func (lrs *layerReader) Name() string {
return lrs.name
}
func (lrs *layerReader) Digest() digest.Digest { func (lrs *layerReader) Digest() digest.Digest {
return lrs.digest return lrs.digest
} }

@ -48,7 +48,6 @@ func (ls *layerStore) Fetch(dgst digest.Digest) (distribution.Layer, error) {
return &layerReader{ return &layerReader{
fileReader: *fr, fileReader: *fr,
name: ls.repository.Name(),
digest: dgst, digest: dgst,
}, nil }, nil
} }

@ -27,11 +27,6 @@ type layerUploadController struct {
var _ distribution.LayerUpload = &layerUploadController{} 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. // UUID returns the identifier for this upload.
func (luc *layerUploadController) UUID() string { func (luc *layerUploadController) UUID() string {
return luc.uuid return luc.uuid
@ -194,7 +189,7 @@ func (luc *layerUploadController) moveLayer(dgst digest.Digest) error {
// named repository for the upload controller. // named repository for the upload controller.
func (luc *layerUploadController) linkLayer(digest digest.Digest) error { func (luc *layerUploadController) linkLayer(digest digest.Digest) error {
layerLinkPath, err := luc.layerStore.repository.registry.pm.path(layerLinkPathSpec{ layerLinkPath, err := luc.layerStore.repository.registry.pm.path(layerLinkPathSpec{
name: luc.Name(), name: luc.layerStore.repository.Name(),
digest: digest, digest: digest,
}) })
@ -210,7 +205,7 @@ func (luc *layerUploadController) linkLayer(digest digest.Digest) error {
// resources are already not present, no error will be returned. // resources are already not present, no error will be returned.
func (luc *layerUploadController) removeResources() error { func (luc *layerUploadController) removeResources() error {
dataPath, err := luc.layerStore.repository.registry.pm.path(uploadDataPathSpec{ dataPath, err := luc.layerStore.repository.registry.pm.path(uploadDataPathSpec{
name: luc.Name(), name: luc.layerStore.repository.Name(),
uuid: luc.uuid, uuid: luc.uuid,
}) })