Skip to content

Commit 30c07b7

Browse files
Merge pull request #3298 from nalind/copy-helper
tests: make it easer to override the location of the copy helper
2 parents 1a70783 + 8acae4b commit 30c07b7

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/helpers.bash

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
BUILDAH_BINARY=${BUILDAH_BINARY:-$(dirname ${BASH_SOURCE})/../bin/buildah}
44
IMGTYPE_BINARY=${IMGTYPE_BINARY:-$(dirname ${BASH_SOURCE})/../bin/imgtype}
5+
COPY_BINARY=${COPY_BINARY:-$(dirname ${BASH_SOURCE})/../bin/copy}
56
TESTSDIR=${TESTSDIR:-$(dirname ${BASH_SOURCE})}
67
STORAGE_DRIVER=${STORAGE_DRIVER:-vfs}
78
PATH=$(dirname ${BASH_SOURCE})/../bin:${PATH}
@@ -33,7 +34,6 @@ function setup() {
3334
ROOTDIR_OPTS="--root ${TESTDIR}/root --runroot ${TESTDIR}/runroot --storage-driver ${STORAGE_DRIVER}"
3435
BUILDAH_REGISTRY_OPTS="--registries-conf ${TESTSDIR}/registries.conf --registries-conf-dir ${TESTDIR}/registries.d --short-name-alias-conf ${TESTDIR}/cache/shortnames.conf"
3536
PODMAN_REGISTRY_OPTS="--registries-conf ${TESTSDIR}/registries.conf"
36-
COPY_OPTS="$ROOTDIR_OPTS $BUILDAH_REGISTRY_OPTS"
3737
}
3838

3939
function starthttpd() {
@@ -96,18 +96,18 @@ function _prefetch() {
9696
fname=$(tr -c a-zA-Z0-9.- - <<< "$img")
9797
if [ -d $_BUILDAH_IMAGE_CACHEDIR/$fname ]; then
9898
echo "# [restoring from cache: $_BUILDAH_IMAGE_CACHEDIR / $img]" >&2
99-
copy $COPY_OPTS dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:"$img"
99+
copy dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:"$img"
100100
else
101101
rm -fr $_BUILDAH_IMAGE_CACHEDIR/$fname
102-
echo "# [copy $COPY_OPTS docker://$img dir:$_BUILDAH_IMAGE_CACHEDIR/$fname]" >&2
102+
echo "# [copy docker://$img dir:$_BUILDAH_IMAGE_CACHEDIR/$fname]" >&2
103103
for attempt in $(seq 3) ; do
104-
if copy $COPY_OPTS docker://"$img" dir:$_BUILDAH_IMAGE_CACHEDIR/$fname ; then
104+
if copy docker://"$img" dir:$_BUILDAH_IMAGE_CACHEDIR/$fname ; then
105105
break
106106
fi
107107
sleep 5
108108
done
109-
echo "# [copy $COPY_OPTS dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:$img]" >&2
110-
copy $COPY_OPTS dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:"$img"
109+
echo "# [copy dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:$img]" >&2
110+
copy dir:$_BUILDAH_IMAGE_CACHEDIR/$fname containers-storage:"$img"
111111
fi
112112
done
113113
}
@@ -124,6 +124,10 @@ function imgtype() {
124124
${IMGTYPE_BINARY} ${ROOTDIR_OPTS} "$@"
125125
}
126126

127+
function copy() {
128+
${COPY_BINARY} ${ROOTDIR_OPTS} ${BUILDAH_REGISTRY_OPTS} "$@"
129+
}
130+
127131
function podman() {
128132
command podman ${PODMAN_REGISTRY_OPTS} ${ROOTDIR_OPTS} "$@"
129133
}

0 commit comments

Comments
 (0)