Add trim name method helper to create name only references

Add a simple helper to create name only references without having
to first get the name as a string and reparse. This method does
not fail so ignoring or checking error to simply trim reference
is not required.

Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
This commit is contained in:
Derek McGowan 2016-11-10 14:46:04 -08:00
parent 4ad885a672
commit 31a91e419c
No known key found for this signature in database
GPG Key ID: F58C5D0A4405ACDB

View File

@ -261,6 +261,11 @@ func Match(pattern string, ref Reference) (bool, error) {
return matched, err return matched, err
} }
// TrimNamed removes any tag or digest from the named reference.
func TrimNamed(ref Named) Named {
return repository(ref.Name())
}
func getBestReferenceType(ref reference) Reference { func getBestReferenceType(ref reference) Reference {
if ref.name == "" { if ref.name == "" {
// Allow digest only references // Allow digest only references