Clarify control flow when handling the tags list

Don't run the the "tags specified" loop when
tags should be discovered.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2020-05-22 01:15:14 +02:00 committed by Valentin Rothberg
parent 677c29bf24
commit 0ae9db5dd6

View File

@ -280,21 +280,21 @@ func imagesToCopyFromRegistry(registryName string, cfg registrySyncConfig, sourc
}).Info("Processing repo") }).Info("Processing repo")
var sourceReferences []types.ImageReference var sourceReferences []types.ImageReference
for _, tag := range tags { if len(tags) != 0 {
source := fmt.Sprintf("%s:%s", repoName, tag) for _, tag := range tags {
source := fmt.Sprintf("%s:%s", repoName, tag)
imageRef, err := docker.ParseReference(source) imageRef, err := docker.ParseReference(source)
if err != nil { if err != nil {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"tag": source, "tag": source,
}).Error("Error processing tag, skipping") }).Error("Error processing tag, skipping")
logrus.Errorf("Error getting image reference: %s", err) logrus.Errorf("Error getting image reference: %s", err)
continue continue
}
sourceReferences = append(sourceReferences, imageRef)
} }
sourceReferences = append(sourceReferences, imageRef) } else { // len(tags) == 0
}
if len(tags) == 0 {
logrus.WithFields(logrus.Fields{ logrus.WithFields(logrus.Fields{
"repo": imageName, "repo": imageName,
"registry": registryName, "registry": registryName,