diff options
author | Miloslav Trmač <mitr@redhat.com> | 2019-01-09 19:41:50 +0100 |
---|---|---|
committer | Miloslav Trmač <mitr@redhat.com> | 2019-01-14 04:07:24 +0100 |
commit | fa42f97507f5b5c661df2339603383b00293689f (patch) | |
tree | 5bb4fc5f9c540b3cdc7de867c45488234ac09403 /libpod/image/parts.go | |
parent | cf40b7161476414e7abecd19d9d9eefacd8a4ef7 (diff) | |
download | podman-fa42f97507f5b5c661df2339603383b00293689f.tar.gz podman-fa42f97507f5b5c661df2339603383b00293689f.tar.bz2 podman-fa42f97507f5b5c661df2339603383b00293689f.zip |
FIXME? Introduce imageParts.suspiciousRefNameTagValuesForSearch
Image.MatchRepoTag and findImageInRepoTags do some kind of
heuristic search; the motivation and design of both, and how they
should deal with digests, is not obvious to me.
Instead of figuring that out now, just factor it out into a
scary-named method and leave the "tag" value (with its "latest"/"none"
value) alone.
Similarly, the .registry and .name fields should typically not be used;
users should use either hasRegistry or normalized reference types;
so, isolate the difficult-to-understand search code, and computation
of these values, into this new search-specific helper.
Should not change behavior.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Diffstat (limited to 'libpod/image/parts.go')
-rw-r--r-- | libpod/image/parts.go | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libpod/image/parts.go b/libpod/image/parts.go index a4eb57519..ab6a86767 100644 --- a/libpod/image/parts.go +++ b/libpod/image/parts.go @@ -76,6 +76,30 @@ func decompose(input string) (imageParts, error) { }, nil } +// suspiciousRefNameTagValuesForSearch returns a "tag" value used in a previous implementation. +// This exists only to preserve existing behavior in heuristic code; it’s dubious that that behavior is correct, +// gespecially for the tag value. +func (ip *imageParts) suspiciousRefNameTagValuesForSearch() (string, string, string) { + registry := reference.Domain(ip.unnormalizedRef) + imageName := reference.Path(ip.unnormalizedRef) + // ip.unnormalizedRef, because it uses reference.Parse and not reference.ParseNormalizedNamed, + // does not use the standard heuristics for domains vs. namespaces/repos. + if registry != "" && !isRegistry(registry) { + imageName = registry + "/" + imageName + registry = "" + } + + var tag string + if tagged, isTagged := ip.unnormalizedRef.(reference.NamedTagged); isTagged { + tag = tagged.Tag() + } else if _, hasDigest := ip.unnormalizedRef.(reference.Digested); hasDigest { + tag = "none" + } else { + tag = "latest" + } + return registry, imageName, tag +} + // referenceWithRegistry returns a (normalized) reference.Named composed of ip (with !ip.hasRegistry) // qualified with registry. func (ip *imageParts) referenceWithRegistry(registry string) (reference.Named, error) { |