From 31a91e419c0e757f98cdce38b1c0e6a6220b12b5 Mon Sep 17 00:00:00 2001 From: Derek McGowan Date: Thu, 10 Nov 2016 14:46:04 -0800 Subject: [PATCH] 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 (github: dmcgowan) --- reference/reference.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/reference/reference.go b/reference/reference.go index 66294cd37..02786628e 100644 --- a/reference/reference.go +++ b/reference/reference.go @@ -261,6 +261,11 @@ func Match(pattern string, ref Reference) (bool, error) { 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 { if ref.name == "" { // Allow digest only references