Use reference.Tagged to extract the tag from a reference

... instead of manually parsing strings.

Should not change behavior, except maybe error messages if the
registry returns invalid tags.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač
2020-05-22 03:25:14 +02:00
committed by Valentin Rothberg
parent 35f3595d02
commit 16b435257b

View File

@@ -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)
}
}