From 347ba2cc253e37e2b4f506133610e3397bca1a99 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= <mitr@redhat.com>
Date: Thu, 19 Jul 2018 00:07:15 +0200
Subject: [PATCH] Split createNamesToPull into
 ref{Names,Pairs}FromPossiblyUnqualifiedName
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

One part creates []*pullRefName; the other just trivially converts it
into []*pullRefPair.

Also use much more explicit names to explain the functionality.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1112
Approved by: rhatdan
---
 libpod/image/pull.go | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index f3b3ad5d9f..bd0a8a382b 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -195,7 +195,7 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
 	srcRef, err := alltransports.ParseImageName(i.InputName)
 	if err != nil {
 		// could be trying to pull from registry with short name
-		pullRefPairs, err = i.createNamesToPull()
+		pullRefPairs, err = i.refPairsFromPossiblyUnqualifiedName()
 		if err != nil {
 			return nil, errors.Wrap(err, "error getting default registries to try")
 		}
@@ -264,9 +264,9 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
 	return images, nil
 }
 
-// createNamesToPull looks at a decomposed image and determines the possible
-// images names to try pulling in combination with the registries.conf file as well
-func (i *Image) createNamesToPull() ([]*pullRefPair, error) {
+// refNamesFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
+// image names to try pulling in combination with the registries.conf file as well
+func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
 	var (
 		pullNames []*pullRefName
 		imageName string
@@ -320,7 +320,17 @@ func (i *Image) createNamesToPull() ([]*pullRefPair, error) {
 			pullNames = append(pullNames, &ps)
 		}
 	}
-	return i.imageruntime.pullRefPairsFromRefNames(pullNames)
+	return pullNames, nil
+}
+
+// refPairsFromPossiblyUnqualifiedName looks at a decomposed image and determines the possible
+// image references to try pulling in combination with the registries.conf file as well
+func (i *Image) refPairsFromPossiblyUnqualifiedName() ([]*pullRefPair, error) {
+	refNames, err := i.refNamesFromPossiblyUnqualifiedName()
+	if err != nil {
+		return nil, err
+	}
+	return i.imageruntime.pullRefPairsFromRefNames(refNames)
 }
 
 // pullRefPairsFromNames converts a []*pullRefName to []*pullRefPair