summaryrefslogtreecommitdiff
path: root/libpod/image/parts.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2018-08-31 07:38:59 -0400
committerAtomic Bot <atomic-devel@projectatomic.io>2018-08-31 18:02:14 +0000
commita917f8fa2a0d9130d84bfda0c40bfe1af68d505c (patch)
treeb2070d31027cd5d6fe914072a06e969133e7edcb /libpod/image/parts.go
parent294c3f4cab3c5945e420a55263a7bece8a7030a1 (diff)
downloadpodman-a917f8fa2a0d9130d84bfda0c40bfe1af68d505c.tar.gz
podman-a917f8fa2a0d9130d84bfda0c40bfe1af68d505c.tar.bz2
podman-a917f8fa2a0d9130d84bfda0c40bfe1af68d505c.zip
We are mistakenly seeing repos as registries.
Currently `podman pull rhel7/rhel-tools` is failing because it sees rhel7 as a registry. This change will verify that the returned registry from the parser is actually a registry and not a repo, if a repo it will return the correct content, and we will pull the image. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com> Closes: #1387 Approved by: mtrmac
Diffstat (limited to 'libpod/image/parts.go')
-rw-r--r--libpod/image/parts.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/libpod/image/parts.go b/libpod/image/parts.go
index 127f723a8..1509005e5 100644
--- a/libpod/image/parts.go
+++ b/libpod/image/parts.go
@@ -2,6 +2,7 @@ package image
import (
"fmt"
+ "strings"
"github.com/containers/image/docker/reference"
)
@@ -16,6 +17,11 @@ type imageParts struct {
hasRegistry bool
}
+// Registries must contain a ":" or a "." or be localhost
+func isRegistry(name string) bool {
+ return strings.ContainsAny(name, ".:") || name == "localhost"
+}
+
// decompose breaks an input name into an imageParts description
func decompose(input string) (imageParts, error) {
var (
@@ -37,10 +43,16 @@ func decompose(input string) (imageParts, error) {
tag = ntag.Tag()
}
registry := reference.Domain(imgRef.(reference.Named))
- if registry != "" {
+ imageName := reference.Path(imgRef.(reference.Named))
+ // Is this a registry or a repo?
+ if isRegistry(registry) {
hasRegistry = true
+ } else {
+ if registry != "" {
+ imageName = registry + "/" + imageName
+ registry = ""
+ }
}
- imageName := reference.Path(imgRef.(reference.Named))
return imageParts{
registry: registry,
hasRegistry: hasRegistry,
@@ -53,10 +65,15 @@ func decompose(input string) (imageParts, error) {
// assemble concatenates an image's parts into a string
func (ip *imageParts) assemble() string {
- return fmt.Sprintf("%s/%s:%s", ip.registry, ip.name, ip.tag)
+ spec := fmt.Sprintf("%s:%s", ip.name, ip.tag)
+
+ if ip.registry != "" {
+ spec = fmt.Sprintf("%s/%s", ip.registry, spec)
+ }
+ return spec
}
// assemble concatenates an image's parts with transport into a string
func (ip *imageParts) assembleWithTransport() string {
- return fmt.Sprintf("%s%s/%s:%s", ip.transport, ip.registry, ip.name, ip.tag)
+ return fmt.Sprintf("%s%s", ip.transport, ip.assemble())
}