From 3b964a4d9a6023375df736cd09f7375805bd3608 Mon Sep 17 00:00:00 2001 From: Miloslav Trmač Date: Thu, 19 Jul 2018 00:11:15 +0200 Subject: Make Image.HasShaInInputName to an independent local function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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č Closes: #1112 Approved by: rhatdan --- libpod/image/image.go | 6 ------ libpod/image/pull.go | 12 +++++++++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/libpod/image/image.go b/libpod/image/image.go index 7ea851f5d..0e236503d 100644 --- a/libpod/image/image.go +++ b/libpod/image/image.go @@ -1074,9 +1074,3 @@ func (i *Image) Comment(ctx context.Context, manifestType string) (string, error } return ociv1Img.History[0].Comment, nil } - -// HasShaInInputName returns a bool as to whether the user provide an image name that includes -// a reference to a specific sha -func (i *Image) HasShaInInputName() bool { - return strings.Contains(i.InputName, "@sha256:") -} 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) -- cgit v1.2.3-54-g00ecf