Remove storageReference.name

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2018-03-09 13:48:23 +01:00
parent 059c0fc4d7
commit 841cbfeabd
5 changed files with 15 additions and 18 deletions

View File

@ -249,7 +249,6 @@ func newImageDestination(imageRef storageReference) (*storageImageDestination, e
// reference that mentions the no-longer-correct digest. // reference that mentions the no-longer-correct digest.
publicRef := imageRef publicRef := imageRef
publicRef.breakDockerReference = true // FIXME: this does not change .StringWithinTransport(), but modifies DockerReference() publicRef.breakDockerReference = true // FIXME: this does not change .StringWithinTransport(), but modifies DockerReference()
publicRef.name = nil
image := &storageImageDestination{ image := &storageImageDestination{
imageRef: imageRef, imageRef: imageRef,
publicRef: publicRef, publicRef: publicRef,

View File

@ -21,11 +21,10 @@ type storageReference struct {
completeReference reference.Named // may include a tag and/or a digest completeReference reference.Named // may include a tag and/or a digest
reference string reference string
id string id string
name reference.Named // May include a tag, not a digest breakDockerReference bool // Possibly set by newImageDestination. FIXME: Figure out another way.
breakDockerReference bool // Possibly set by newImageDestination. FIXME: Figure out another way.
} }
func newReference(transport storageTransport, completeReference reference.Named, reference, id string, name reference.Named) *storageReference { func newReference(transport storageTransport, completeReference reference.Named, reference, id string) *storageReference {
// We take a copy of the transport, which contains a pointer to the // We take a copy of the transport, which contains a pointer to the
// store that it used for resolving this reference, so that the // store that it used for resolving this reference, so that the
// transport that we'll return from Transport() won't be affected by // transport that we'll return from Transport() won't be affected by
@ -35,7 +34,6 @@ func newReference(transport storageTransport, completeReference reference.Named,
completeReference: completeReference, completeReference: completeReference,
reference: reference, reference: reference,
id: id, id: id,
name: name,
} }
} }

View File

@ -136,24 +136,24 @@ func TestParse(t *testing.T) {
} }
_references := []storageReference{ _references := []storageReference{
{ {
name: ref.(*storageReference).name, completeReference: ref.(*storageReference).completeReference,
reference: ref.(*storageReference).name.String(), reference: ref.(*storageReference).completeReference.String(),
id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
transport: transport, transport: transport,
}, },
{ {
name: ref.(*storageReference).name, completeReference: ref.(*storageReference).completeReference,
reference: ref.(*storageReference).name.String(), reference: ref.(*storageReference).completeReference.String(),
transport: transport, transport: transport,
}, },
{ {
id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", id: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
transport: transport, transport: transport,
}, },
{ {
name: ref.DockerReference(), completeReference: ref.DockerReference(),
reference: ref.DockerReference().String(), reference: ref.DockerReference().String(),
transport: transport, transport: transport,
}, },
} }
for _, reference := range _references { for _, reference := range _references {

View File

@ -245,7 +245,7 @@ func (s storageTransport) ParseStoreReference(store storage.Store, ref string) (
} else { } else {
logrus.Debugf("parsed reference to refname@id into %q", storeSpec+refname+"@"+id) logrus.Debugf("parsed reference to refname@id into %q", storeSpec+refname+"@"+id)
} }
return newReference(storageTransport{store: store, defaultUIDMap: s.defaultUIDMap, defaultGIDMap: s.defaultGIDMap}, completeReference, refname, id, name), nil return newReference(storageTransport{store: store, defaultUIDMap: s.defaultUIDMap, defaultGIDMap: s.defaultGIDMap}, completeReference, refname, id), nil
} }
func (s *storageTransport) GetStore() (storage.Store, error) { func (s *storageTransport) GetStore() (storage.Store, error) {

View File

@ -74,11 +74,11 @@ func TestTransportParseStoreReference(t *testing.T) {
assert.Equal(t, c.expectedRef, storageRef.reference, c.input) assert.Equal(t, c.expectedRef, storageRef.reference, c.input)
assert.Equal(t, c.expectedID, storageRef.id, c.input) assert.Equal(t, c.expectedID, storageRef.id, c.input)
if c.expectedRef == "" { if c.expectedRef == "" {
assert.Nil(t, storageRef.name, c.input) assert.Nil(t, storageRef.completeReference, c.input)
} else { } else {
dockerRef, err := reference.ParseNormalizedNamed(c.expectedRef) dockerRef, err := reference.ParseNormalizedNamed(c.expectedRef)
require.NoError(t, err) require.NoError(t, err)
require.NotNil(t, storageRef.name, c.input) require.NotNil(t, storageRef.completeReference, c.input)
assert.Equal(t, dockerRef.String(), storageRef.reference) assert.Equal(t, dockerRef.String(), storageRef.reference)
assert.Equal(t, dockerRef.String(), storageRef.DockerReference().String()) assert.Equal(t, dockerRef.String(), storageRef.DockerReference().String())
} }