summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/image/image.go8
-rw-r--r--libpod/image/parts.go36
-rw-r--r--libpod/image/parts_test.go4
-rw-r--r--libpod/image/pull.go4
-rw-r--r--libpod/image/utils.go6
5 files changed, 26 insertions, 32 deletions
diff --git a/libpod/image/image.go b/libpod/image/image.go
index dda753385..b51aced49 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -25,7 +25,7 @@ import (
"github.com/containers/libpod/pkg/util"
"github.com/containers/storage"
"github.com/containers/storage/pkg/reexec"
- "github.com/opencontainers/go-digest"
+ digest "github.com/opencontainers/go-digest"
ociv1 "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
@@ -460,7 +460,7 @@ func normalizeTag(tag string) (string, error) {
}
// If the input does not have a tag, we need to add one (latest)
if !decomposedTag.isTagged {
- tag = fmt.Sprintf("%s:%s", tag, decomposedTag.Tag)
+ tag = fmt.Sprintf("%s:%s", tag, decomposedTag.tag)
}
// If the input doesn't specify a registry, set the registry to localhost
if !decomposedTag.hasRegistry {
@@ -937,7 +937,7 @@ func (i *Image) MatchRepoTag(input string) (string, error) {
if err != nil {
return "", err
}
- if dcRepoName.Registry == dcImage.Registry && dcImage.Registry != "" {
+ if dcRepoName.registry == dcImage.registry && dcImage.registry != "" {
count++
}
if dcRepoName.name == dcImage.name && dcImage.name != "" {
@@ -945,7 +945,7 @@ func (i *Image) MatchRepoTag(input string) (string, error) {
} else if splitString(dcRepoName.name) == splitString(dcImage.name) {
count++
}
- if dcRepoName.Tag == dcImage.Tag {
+ if dcRepoName.tag == dcImage.tag {
count++
}
results[count] = append(results[count], repoName)
diff --git a/libpod/image/parts.go b/libpod/image/parts.go
index b2a69f26c..9adf26fb9 100644
--- a/libpod/image/parts.go
+++ b/libpod/image/parts.go
@@ -7,12 +7,12 @@ import (
"github.com/containers/image/docker/reference"
)
-// Parts describes the parts of an image's name
-type Parts struct {
+// imageParts describes the parts of an image's name
+type imageParts struct {
transport string
- Registry string
+ registry string
name string
- Tag string
+ tag string
isTagged bool
hasRegistry bool
}
@@ -34,16 +34,10 @@ func GetImageBaseName(input string) (string, error) {
return splitImageName[len(splitImageName)-1], nil
}
-// DecomposeString decomposes a string name into imageParts description. This
-// is a wrapper for decompose
-func DecomposeString(input string) (Parts, error) {
- return decompose(input)
-}
-
// decompose breaks an input name into an imageParts description
-func decompose(input string) (Parts, error) {
+func decompose(input string) (imageParts, error) {
var (
- parts Parts
+ parts imageParts
hasRegistry bool
tag string
)
@@ -62,7 +56,7 @@ func decompose(input string) (Parts, error) {
}
registry := reference.Domain(imgRef.(reference.Named))
imageName := reference.Path(imgRef.(reference.Named))
- // Is this a Registry or a repo?
+ // Is this a registry or a repo?
if isRegistry(registry) {
hasRegistry = true
} else {
@@ -71,27 +65,27 @@ func decompose(input string) (Parts, error) {
registry = ""
}
}
- return Parts{
- Registry: registry,
+ return imageParts{
+ registry: registry,
hasRegistry: hasRegistry,
name: imageName,
- Tag: tag,
+ tag: tag,
isTagged: isTagged,
transport: DefaultTransport,
}, nil
}
// assemble concatenates an image's parts into a string
-func (ip *Parts) assemble() string {
- spec := fmt.Sprintf("%s:%s", ip.name, ip.Tag)
+func (ip *imageParts) assemble() string {
+ spec := fmt.Sprintf("%s:%s", ip.name, ip.tag)
- if ip.Registry != "" {
- spec = fmt.Sprintf("%s/%s", ip.Registry, spec)
+ 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 *Parts) assembleWithTransport() string {
+func (ip *imageParts) assembleWithTransport() string {
return fmt.Sprintf("%s%s", ip.transport, ip.assemble())
}
diff --git a/libpod/image/parts_test.go b/libpod/image/parts_test.go
index 1e01c85d3..518538f0b 100644
--- a/libpod/image/parts_test.go
+++ b/libpod/image/parts_test.go
@@ -55,9 +55,9 @@ func TestDecompose(t *testing.T) {
} else {
assert.NoError(t, err, c.input)
assert.Equal(t, c.transport, parts.transport, c.input)
- assert.Equal(t, c.registry, parts.Registry, c.input)
+ assert.Equal(t, c.registry, parts.registry, c.input)
assert.Equal(t, c.name, parts.name, c.input)
- assert.Equal(t, c.tag, parts.Tag, c.input)
+ assert.Equal(t, c.tag, parts.tag, c.input)
assert.Equal(t, c.isTagged, parts.isTagged, c.input)
assert.Equal(t, c.hasRegistry, parts.hasRegistry, c.input)
assert.Equal(t, c.assembled, parts.assemble(), c.input)
diff --git a/libpod/image/pull.go b/libpod/image/pull.go
index 203e94310..09935fe7c 100644
--- a/libpod/image/pull.go
+++ b/libpod/image/pull.go
@@ -76,7 +76,7 @@ func (ir *Runtime) getPullRefPair(srcRef types.ImageReference, destName string)
decomposedDest, err := decompose(destName)
if err == nil && !decomposedDest.hasRegistry {
// If the image doesn't have a registry, set it as the default repo
- decomposedDest.Registry = DefaultLocalRegistry
+ decomposedDest.registry = DefaultLocalRegistry
decomposedDest.hasRegistry = true
destName = decomposedDest.assemble()
}
@@ -317,7 +317,7 @@ func (ir *Runtime) pullGoalFromPossiblyUnqualifiedName(inputName string) (*pullG
}
var refPairs []pullRefPair
for _, registry := range searchRegistries {
- decomposedImage.Registry = registry
+ decomposedImage.registry = registry
imageName := decomposedImage.assembleWithTransport()
if hasShaInInputName(inputName) {
imageName = fmt.Sprintf("%s%s/%s", decomposedImage.transport, registry, inputName)
diff --git a/libpod/image/utils.go b/libpod/image/utils.go
index 135b47008..b944de1bb 100644
--- a/libpod/image/utils.go
+++ b/libpod/image/utils.go
@@ -16,7 +16,7 @@ import (
// findImageInRepotags takes an imageParts struct and searches images' repotags for
// a match on name:tag
-func findImageInRepotags(search Parts, images []*Image) (*storage.Image, error) {
+func findImageInRepotags(search imageParts, images []*Image) (*storage.Image, error) {
var results []*storage.Image
for _, image := range images {
for _, name := range image.Names() {
@@ -25,12 +25,12 @@ func findImageInRepotags(search Parts, images []*Image) (*storage.Image, error)
if err != nil {
continue
}
- if d.name == search.name && d.Tag == search.Tag {
+ if d.name == search.name && d.tag == search.tag {
results = append(results, image.image)
continue
}
// account for registry:/somedir/image
- if strings.HasSuffix(d.name, search.name) && d.Tag == search.Tag {
+ if strings.HasSuffix(d.name, search.name) && d.tag == search.tag {
results = append(results, image.image)
continue
}