diff options
author | Miloslav Trmač <mitr@redhat.com> | 2018-07-28 06:33:11 +0200 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-08-01 18:22:59 +0000 |
commit | 8d73e456631ac283eb238584f963ee0df8c84973 (patch) | |
tree | 1c15245fab93fc6dc698db445ab7cbde543fb531 /libpod/image/pull_test.go | |
parent | 5eac0740c3d57150af39a3da26fb680744213bd1 (diff) | |
download | podman-8d73e456631ac283eb238584f963ee0df8c84973.tar.gz podman-8d73e456631ac283eb238584f963ee0df8c84973.tar.bz2 podman-8d73e456631ac283eb238584f963ee0df8c84973.zip |
Eliminate duplicate determination whether to use search registries
Instead of duplicating the hasRegistry logic, just record whether we
did use search or not.
Should not change behavior (but does not add unit tests for all of it).
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Closes: #1176
Approved by: rhatdan
Diffstat (limited to 'libpod/image/pull_test.go')
-rw-r--r-- | libpod/image/pull_test.go | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/libpod/image/pull_test.go b/libpod/image/pull_test.go index af8bf14a5..3a914526d 100644 --- a/libpod/image/pull_test.go +++ b/libpod/image/pull_test.go @@ -199,6 +199,7 @@ func TestPullGoalNamesFromImageReference(t *testing.T) { assert.Equal(t, pullRefName{image: e.image, srcRef: srcRef, dstName: e.dstName}, res.refNames[i], fmt.Sprintf("%s #%d", c.srcName, i)) } assert.Equal(t, c.expectedPullAllPairs, res.pullAllPairs, c.srcName) + assert.False(t, res.usedSearchRegistries, c.srcName) } } } @@ -232,37 +233,43 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { os.Setenv("REGISTRIES_CONFIG_PATH", registriesConf.Name()) for _, c := range []struct { - input string - expected []pullRefStrings + input string + expected []pullRefStrings + expectedUsedSearchRegistries bool }{ - {"#", nil}, // Clearly invalid. + {"#", nil, false}, // Clearly invalid. { // Fully-explicit docker.io, name-only. "docker.io/library/busybox", // (The docker:// representation is shortened by c/image/docker.Reference but it refers to "docker.io/library".) []pullRefStrings{{"docker.io/library/busybox", "docker://busybox:latest", "docker.io/library/busybox"}}, + false, }, { // docker.io with implied /library/, name-only. "docker.io/busybox", // (The docker:// representation is shortened by c/image/docker.Reference but it refers to "docker.io/library".) // The .dstName fields differ for the explicit/implicit /library/ cases, but StorageTransport.ParseStoreReference normalizes that. []pullRefStrings{{"docker.io/busybox", "docker://busybox:latest", "docker.io/busybox"}}, + false, }, { // Qualified example.com, name-only. "example.com/ns/busybox", []pullRefStrings{{"example.com/ns/busybox", "docker://example.com/ns/busybox:latest", "example.com/ns/busybox"}}, + false, }, { // Qualified example.com, name:tag. "example.com/ns/busybox:notlatest", []pullRefStrings{{"example.com/ns/busybox:notlatest", "docker://example.com/ns/busybox:notlatest", "example.com/ns/busybox:notlatest"}}, + false, }, { // Qualified example.com, name@digest. "example.com/ns/busybox" + digestSuffix, []pullRefStrings{{"example.com/ns/busybox" + digestSuffix, "docker://example.com/ns/busybox" + digestSuffix, // FIXME?! Why is .dstName dropping the digest, and adding :none?! "example.com/ns/busybox:none"}}, + false, }, // Qualified example.com, name:tag@digest. This code is happy to try, but .srcRef parsing currently rejects such input. - {"example.com/ns/busybox:notlatest" + digestSuffix, nil}, + {"example.com/ns/busybox:notlatest" + digestSuffix, nil, false}, { // Unqualified, single-name, name-only "busybox", []pullRefStrings{ @@ -270,6 +277,7 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { // (The docker:// representation is shortened by c/image/docker.Reference but it refers to "docker.io/library".) {"docker.io/busybox:latest", "docker://busybox:latest", "docker.io/busybox:latest"}, }, + true, }, { // Unqualified, namespaced, name-only "ns/busybox", @@ -278,6 +286,7 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { []pullRefStrings{ {"ns/busybox", "docker://ns/busybox:latest", "ns/busybox"}, }, + false, }, { // Unqualified, name:tag "busybox:notlatest", @@ -286,6 +295,7 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { // (The docker:// representation is shortened by c/image/docker.Reference but it refers to "docker.io/library".) {"docker.io/busybox:notlatest", "docker://busybox:notlatest", "docker.io/busybox:notlatest"}, }, + true, }, { // Unqualified, name@digest "busybox" + digestSuffix, @@ -295,9 +305,10 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { // (The docker:// representation is shortened by c/image/docker.Reference but it refers to "docker.io/library".) {"docker.io/busybox:none", "docker://busybox" + digestSuffix, "docker.io/busybox:none"}, }, + true, }, // Unqualified, name:tag@digest. This code is happy to try, but .srcRef parsing currently rejects such input. - {"busybox:notlatest" + digestSuffix, nil}, + {"busybox:notlatest" + digestSuffix, nil, false}, } { res, err := pullGoalNamesFromPossiblyUnqualifiedName(c.input) if len(c.expected) == 0 { @@ -314,6 +325,7 @@ func TestPullGoalNamesFromPossiblyUnqualifiedName(t *testing.T) { } assert.Equal(t, c.expected, strings, c.input) assert.False(t, res.pullAllPairs, c.input) + assert.Equal(t, c.expectedUsedSearchRegistries, res.usedSearchRegistries, c.input) } } } |