summaryrefslogtreecommitdiff
path: root/libpod/image
diff options
context:
space:
mode:
authorMiloslav Trmač <mitr@redhat.com>2018-07-28 02:36:12 +0200
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-01 18:22:58 +0000
commit1153486ab004ce1234305de295c753085c9b1356 (patch)
tree1f210e072e749c7d48960b99a11124d8c0e91204 /libpod/image
parent190e0744599e972e4a00ef3a9184cd82c87b5282 (diff)
downloadpodman-1153486ab004ce1234305de295c753085c9b1356.tar.gz
podman-1153486ab004ce1234305de295c753085c9b1356.tar.bz2
podman-1153486ab004ce1234305de295c753085c9b1356.zip
Don't format to string and re-parse a DockerReference()
We already have a c/image/docker/reference.Named; no need to round-trip it through a string. This also eliminates the theoretical parsing failure, and the unchecked .(reference.Named) cast. Also add a check for DockerReference() == nil to be extra paranoid, although that should never happen. Should not change behavior (but does not add unit tests). Signed-off-by: Miloslav Trmač <mitr@redhat.com> Closes: #1176 Approved by: rhatdan
Diffstat (limited to 'libpod/image')
-rw-r--r--libpod/image/image.go9
-rw-r--r--libpod/image/pull.go10
2 files changed, 11 insertions, 8 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 914b8f754..3abaecc6c 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -15,6 +15,7 @@ import (
"github.com/containers/image/manifest"
is "github.com/containers/image/storage"
"github.com/containers/image/tarball"
+ "github.com/containers/image/transports"
"github.com/containers/image/transports/alltransports"
"github.com/containers/image/types"
"github.com/containers/storage"
@@ -552,11 +553,11 @@ func (i *Image) PushImage(ctx context.Context, destination, manifestMIMEType, au
}
copyOptions := getCopyOptions(writer, signaturePolicyPath, nil, dockerRegistryOptions, signingOptions, authFile, manifestMIMEType, forceCompress, additionalDockerArchiveTags)
if dest.Transport().Name() == DockerTransport {
- imgRef, err := reference.Parse(dest.DockerReference().String())
- if err != nil {
- return err
+ imgRef := dest.DockerReference()
+ if imgRef == nil { // This should never happen; such references can’t be created.
+ return fmt.Errorf("internal error: DockerTransport reference %s does not have a DockerReference", transports.ImageName(dest))
}
- registry := reference.Domain(imgRef.(reference.Named))
+ registry := reference.Domain(imgRef)
if util.StringInSlice(registry, insecureRegistries) && !forceSecure {
copyOptions.DestinationCtx.DockerInsecureSkipTLSVerify = true
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 69c7de6ff..43d1ab837 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -16,6 +16,7 @@ import (
"github.com/containers/image/pkg/sysregistries"
is "github.com/containers/image/storage"
"github.com/containers/image/tarball"
+ "github.com/containers/image/transports"
"github.com/containers/image/transports/alltransports"
"github.com/containers/image/types"
"github.com/pkg/errors"
@@ -207,11 +208,12 @@ func (i *Image) pullImage(ctx context.Context, writer io.Writer, authfile, signa
for _, imageInfo := range pullRefPairs {
copyOptions := getCopyOptions(writer, signaturePolicyPath, dockerOptions, nil, signingOptions, authfile, "", false, nil)
if imageInfo.srcRef.Transport().Name() == DockerTransport {
- imgRef, err := reference.Parse(imageInfo.srcRef.DockerReference().String())
- if err != nil {
- return nil, err
+ imgRef := imageInfo.srcRef.DockerReference()
+ if imgRef == nil { // This should never happen; such references can’t be created.
+ return nil, fmt.Errorf("internal error: DockerTransport reference %s does not have a DockerReference",
+ transports.ImageName(imageInfo.srcRef))
}
- registry := reference.Domain(imgRef.(reference.Named))
+ registry := reference.Domain(imgRef)
if util.StringInSlice(registry, insecureRegistries) && !forceSecure {
copyOptions.SourceCtx.DockerInsecureSkipTLSVerify = true