Files
skopeo/tests/registries.bats
Nalin Dahyabhai 47ac96155f Use configured registries to resolve image names
When locating an image for pulling, inspection, or pushing, if we're
given an image name that doesn't include a domain/registry, try building
a set of candidate names using the configured registries as domains, and
then pull/inspect/push using the first of those names that works.

If a name that we're given corresponds to a prefix of the ID of a local
image, skip completion and use the ID directly instead.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #360
Approved by: rhatdan
2017-12-14 22:21:16 +00:00

58 lines
1.7 KiB
Bash

#!/usr/bin/env bats
load helpers
@test "registries" {
registrypair() {
image=$1
imagename=$2
# Clean up.
for id in $(buildah --debug=false containers -q) ; do
buildah rm ${id}
done
for id in $(buildah --debug=false images -q) ; do
buildah rmi ${id}
done
# Create a container by specifying the image with one name.
buildah from --pull --signature-policy ${TESTSDIR}/policy.json $image
# Create a container by specifying the image with another name.
buildah from --pull --signature-policy ${TESTSDIR}/policy.json $imagename
# Get their image IDs. They should be the same one.
lastid=
for cid in $(buildah --debug=false containers -q) ; do
run buildah --debug=false inspect -f "{{.FromImageID}}" $cid
echo "$output"
[ $status -eq 0 ]
[ $(wc -l <<< "$output") -eq 1 ]
if [ "$lastid" != "" ] ; then
[ "$output" = "$lastid" ]
fi
lastid="$output"
done
# A quick bit of troubleshooting help.
run buildah images
echo "$output"
[ "$iid" = "$nameiid" ]
# Clean up.
for id in $(buildah --debug=false containers -q) ; do
buildah rm ${id}
done
for id in $(buildah --debug=false images -q) ; do
buildah rmi ${id}
done
}
# Test with pairs of short and fully-qualified names that should be the same image.
registrypair busybox docker.io/busybox
registrypair docker.io/busybox busybox
registrypair busybox docker.io/library/busybox
registrypair docker.io/library/busybox busybox
registrypair fedora-minimal registry.fedoraproject.org/fedora-minimal
registrypair registry.fedoraproject.org/fedora-minimal fedora-minimal
}