summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2019-02-13 09:17:31 -0600
committerbaude <bbaude@redhat.com>2019-02-13 11:05:20 -0600
commitf29a11c201a67a82ca2b82d314a57043207aa1ac (patch)
tree037f60f26e99039defe3161a8595274c58cb5fe0
parentee27c39f85507993c0a3dfe3c4dfab4c7b7e5e00 (diff)
downloadpodman-f29a11c201a67a82ca2b82d314a57043207aa1ac.tar.gz
podman-f29a11c201a67a82ca2b82d314a57043207aa1ac.tar.bz2
podman-f29a11c201a67a82ca2b82d314a57043207aa1ac.zip
Parse fq name correctly for images
When parsing a string name for repo and tag (for images output), we should be using parsenormalizedname and reference.Canonical to get the proper output. Resolves: #2175 Signed-off-by: baude <bbaude@redhat.com>
-rw-r--r--cmd/podman/images.go6
-rw-r--r--libpod/image/utils.go17
2 files changed, 17 insertions, 6 deletions
diff --git a/cmd/podman/images.go b/cmd/podman/images.go
index a9e8abbde..b269f6440 100644
--- a/cmd/podman/images.go
+++ b/cmd/podman/images.go
@@ -247,8 +247,12 @@ func getImagesTemplateOutput(ctx context.Context, images []*adapter.ContainerIma
}
// get all specified repo:tag pairs and print them separately
+ repopairs, err := image.ReposToMap(img.Names())
+ if err != nil {
+ logrus.Errorf("error finding tag/digest for %s", img.ID())
+ }
outer:
- for repo, tags := range image.ReposToMap(img.Names()) {
+ for repo, tags := range repopairs {
for _, tag := range tags {
size, err := img.Size(ctx)
var sizeStr string
diff --git a/libpod/image/utils.go b/libpod/image/utils.go
index ad027f32a..3585428ad 100644
--- a/libpod/image/utils.go
+++ b/libpod/image/utils.go
@@ -87,22 +87,29 @@ func hasTransport(image string) bool {
// ReposToMap parses the specified repotags and returns a map with repositories
// as keys and the corresponding arrays of tags as values.
-func ReposToMap(repotags []string) map[string][]string {
+func ReposToMap(repotags []string) (map[string][]string, error) {
// map format is repo -> tag
repos := make(map[string][]string)
for _, repo := range repotags {
var repository, tag string
if len(repo) > 0 {
- li := strings.LastIndex(repo, ":")
- repository = repo[0:li]
- tag = repo[li+1:]
+ named, err := reference.ParseNormalizedNamed(repo)
+ repository = named.Name()
+ if err != nil {
+ return nil, err
+ }
+ if ref, ok := named.(reference.NamedTagged); ok {
+ tag = ref.Tag()
+ } else if ref, ok := named.(reference.Canonical); ok {
+ tag = ref.Digest().String()
+ }
}
repos[repository] = append(repos[repository], tag)
}
if len(repos) == 0 {
repos["<none>"] = []string{"<none>"}
}
- return repos
+ return repos, nil
}
// GetAdditionalTags returns a list of reference.NamedTagged for the