summaryrefslogtreecommitdiff
path: root/libpod/image/pull.go
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-19 00:11:15 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-07-23 12:44:38 +0000
commit3b964a4d9a6023375df736cd09f7375805bd3608 (patch)
tree8d3b479ac45270ebbc4da78edd0602cdac1ab78c /libpod/image/pull.go
parent347ba2cc253e37e2b4f506133610e3397bca1a99 (diff)
downloadpodman-3b964a4d9a6023375df736cd09f7375805bd3608.tar.gz
podman-3b964a4d9a6023375df736cd09f7375805bd3608.tar.bz2
podman-3b964a4d9a6023375df736cd09f7375805bd3608.zip
Make Image.HasShaInInputName to an independent local function
The functionality only depends on Image.InputName, and we will want to make the only user of this independent of the fairly complex Image type. Should not change behavior. Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1112 Approved by: rhatdan
Diffstat (limited to 'libpod/image/pull.go')
-rw-r--r--libpod/image/pull.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index bd0a8a382..529378019 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -264,6 +264,12 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
return images, nil
}
+// hasShaInInputName returns a bool as to whether the user provided an image name that includes
+// a reference to a specific sha
+func hasShaInInputName(inputName string) bool {
+ return strings.Contains(inputName, "@sha256:")
+}
+
// 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) {
@@ -277,7 +283,7 @@ func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
return nil, err
}
if decomposedImage.hasRegistry {
- if i.HasShaInInputName() {
+ if hasShaInInputName(i.InputName) {
imageName = fmt.Sprintf("%s%s", decomposedImage.transport, i.InputName)
} else {
imageName = decomposedImage.assembleWithTransport()
@@ -290,7 +296,7 @@ func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
image: i.InputName,
srcRef: srcRef,
}
- if i.HasShaInInputName() {
+ if hasShaInInputName(i.InputName) {
ps.dstName = decomposedImage.assemble()
} else {
ps.dstName = ps.image
@@ -305,7 +311,7 @@ func (i *Image) refNamesFromPossiblyUnqualifiedName() ([]*pullRefName, error) {
for _, registry := range searchRegistries {
decomposedImage.registry = registry
imageName := decomposedImage.assembleWithTransport()
- if i.HasShaInInputName() {
+ if hasShaInInputName(i.InputName) {
imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, i.InputName)
}
srcRef, err := alltransports.ParseImageName(imageName)