Merge pull request #30889 from aaronlehmann/addreference-tag-digest
reference: Handle combination of tag and digest in AddReference
This commit is contained in:
commit
584e399d96
1 changed files with 14 additions and 0 deletions
|
@ -107,6 +107,20 @@ func (store *store) AddDigest(ref reference.Canonical, id digest.Digest, force b
|
|||
}
|
||||
|
||||
func (store *store) addReference(ref reference.Named, id digest.Digest, force bool) error {
|
||||
// If the reference includes a digest and a tag, we must store only the
|
||||
// digest.
|
||||
canonical, isCanonical := ref.(reference.Canonical)
|
||||
_, isNamedTagged := ref.(reference.NamedTagged)
|
||||
|
||||
if isCanonical && isNamedTagged {
|
||||
trimmed, err := reference.WithDigest(reference.TrimNamed(canonical), canonical.Digest())
|
||||
if err != nil {
|
||||
// should never happen
|
||||
return err
|
||||
}
|
||||
ref = trimmed
|
||||
}
|
||||
|
||||
refName := reference.FamiliarName(ref)
|
||||
refStr := reference.FamiliarString(ref)
|
||||
|
||||
|
|
Loading…
Reference in a new issue