Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Wrap use of skopeo to avoid its unwanted side effects. #570

Merged
merged 1 commit into from
Dec 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 23 additions & 5 deletions test/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,24 @@ function zot_teardown {
rm -f $TEST_TMPDIR/zot-config.json
}

function _skopeo() {
[ "$1" = "--version" ] && {
"$SKOPEO" "$@"
return
}
local uid=""
uid=$(id -u)
if [ ! -e /run/containers ]; then
if [ "$uid" = "0" ]; then
mkdir --mode=755 /run/containers || chmod /run/containers 755
fi
fi
[ -n "$TEST_TMPDIR" ]
local home="${TEST_TMPDIR}/home"
[ -d "$home" ] || mkdir -p "$home"
HOME="$home" "$SKOPEO" "$@"
}

function test_copy_buffer_size() {
local buffer_size=$1
local file_type=$2
Expand Down Expand Up @@ -244,13 +262,13 @@ EOF
m1=$(cat oci/index.json | jq .manifests[0].digest | sed 's/sha256://' | tr -d \")
cat oci/blobs/sha256/"$m1" | jq .
l1=$(cat oci/blobs/sha256/"$m1" | jq .layers[0].digest | sed 's/sha256://' | tr -d \")
$SKOPEO --version
[[ "$($SKOPEO --version)" =~ "skopeo version ${SKOPEO_VERSION}" ]] || {
_skopeo --version
[[ "$(_skopeo --version)" =~ "skopeo version ${SKOPEO_VERSION}" ]] || {
echo "$SKOPEO --version should be ${SKOPEO_VERSION}"
exit 1
}
$SKOPEO copy --format=oci oci:oci:tar containers-storage:test:tar
$SKOPEO copy --format=oci containers-storage:test:tar oci:oci:test
_skopeo copy --format=oci oci:oci:tar containers-storage:test:tar
_skopeo copy --format=oci containers-storage:test:tar oci:oci:test
cat oci/index.json | jq .
m2=$(cat oci/index.json | jq .manifests[1].digest | sed 's/sha256://' | tr -d \")
cat oci/blobs/sha256/"$m2" | jq .
Expand All @@ -261,5 +279,5 @@ EOF
stacker clean
rm -rf folder1
cd "$ROOT_DIR"
rm -rf "tmpdir"
rm -rf "$tmpdir"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

worth mentioning you fixed a case where we left a tmpdir around when using test_copy_buffer_size I think.

}
Loading