From 16b435257be3826605ccb1cc89066cc9ffffecb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Fri, 22 May 2020 03:25:14 +0200 Subject: [PATCH] Use reference.Tagged to extract the tag from a reference MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... instead of manually parsing strings. Should not change behavior, except maybe error messages if the registry returns invalid tags. Signed-off-by: Miloslav Trmač --- cmd/skopeo/sync.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/skopeo/sync.go b/cmd/skopeo/sync.go index e16e1641..71212879 100644 --- a/cmd/skopeo/sync.go +++ b/cmd/skopeo/sync.go @@ -359,8 +359,12 @@ func imagesToCopyFromRegistry(registryName string, cfg registrySyncConfig, sourc repoLogger.Infof("Start filtering using the regular expression: %v", tagRegex) for _, sReference := range allSourceReferences { - // get the tag names to match, [1] default is "latest" by .DockerReference().String() - if tagReg.Match([]byte(strings.Split(sReference.DockerReference().String(), ":")[1])) { + tagged, isTagged := sReference.DockerReference().(reference.Tagged) + if !isTagged { + repoLogger.Errorf("Internal error, reference %s does not have a tag, skipping", sReference.DockerReference()) + continue + } + if tagReg.Match([]byte(tagged.Tag())) { sourceReferences = append(sourceReferences, sReference) } }