From 0ae9db5dd652c7c62d29ebb8cee498b9ad2ea5aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Fri, 22 May 2020 01:15:14 +0200 Subject: [PATCH] Clarify control flow when handling the tags list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't run the the "tags specified" loop when tags should be discovered. Should not change behavior. Signed-off-by: Miloslav Trmač --- cmd/skopeo/sync.go | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/cmd/skopeo/sync.go b/cmd/skopeo/sync.go index f9062432..8602f041 100644 --- a/cmd/skopeo/sync.go +++ b/cmd/skopeo/sync.go @@ -280,21 +280,21 @@ func imagesToCopyFromRegistry(registryName string, cfg registrySyncConfig, sourc }).Info("Processing repo") var sourceReferences []types.ImageReference - for _, tag := range tags { - source := fmt.Sprintf("%s:%s", repoName, tag) + if len(tags) != 0 { + for _, tag := range tags { + source := fmt.Sprintf("%s:%s", repoName, tag) - imageRef, err := docker.ParseReference(source) - if err != nil { - logrus.WithFields(logrus.Fields{ - "tag": source, - }).Error("Error processing tag, skipping") - logrus.Errorf("Error getting image reference: %s", err) - continue + imageRef, err := docker.ParseReference(source) + if err != nil { + logrus.WithFields(logrus.Fields{ + "tag": source, + }).Error("Error processing tag, skipping") + logrus.Errorf("Error getting image reference: %s", err) + continue + } + sourceReferences = append(sourceReferences, imageRef) } - sourceReferences = append(sourceReferences, imageRef) - } - - if len(tags) == 0 { + } else { // len(tags) == 0 logrus.WithFields(logrus.Fields{ "repo": imageName, "registry": registryName,