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

Improve SHA query for different registries #493

Merged
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
19 changes: 11 additions & 8 deletions hack/pin-bundle-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,28 +31,31 @@ for MOD_PATH in $(go list -mod=readonly -m -json all | jq -r '. | select(.Path |
REF=$(git ls-remote https://${GIT_REPO} | grep ${REF} | awk 'NR==1{print $1}')
fi
GITHUB_USER=$(echo $MOD_PATH | sed -e 's|github.com/\(.*\)/.*-operator/.*$|\1|')
REPO_CURL_URL="https://quay.io/api/v1/repository/openstack-k8s-operators"
REPO_URL="quay.io/openstack-k8s-operators"
CURL_REGISTRY="quay.io"
viroel marked this conversation as resolved.
Show resolved Hide resolved
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/openstack-k8s-operators"
REPO_URL="${CURL_REGISTRY}/openstack-k8s-operators"
if [[ "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ]]; then
if [[ "$IMAGENAMESPACE" != "openstack-k8s-operators" || "${IMAGEREGISTRY}" != "quay.io" ]]; then
REPO_URL="${IMAGEREGISTRY}/${IMAGENAMESPACE}"
CURL_REGISTRY="${IMAGEREGISTRY}"
# Quay registry v2 api does not return all the tags that's why keeping v1 for quay and v2
# for local registry
if [[ ${LOCAL_REGISTRY} -eq 1 ]]; then
REPO_CURL_URL="${IMAGEREGISTRY}/v2/${IMAGENAMESPACE}"
REPO_CURL_URL="${CURL_REGISTRY}/v2/${IMAGENAMESPACE}"
else
REPO_CURL_URL="https://${IMAGEREGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
fi
else
REPO_CURL_URL="https://quay.io/api/v1/repository/${GITHUB_USER}"
REPO_URL="quay.io/${GITHUB_USER}"
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
fi
fi

if [[ ${LOCAL_REGISTRY} -eq 1 && ( "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/list | jq -r .tags[] | sort -u | grep $REF)
elif [[ "${IMAGEREGISTRY}" != "quay.io" ]]; then
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tag/ | jq -r .tags[].name | sort -u | grep $REF)
elif [[ "${CURL_REGISTRY}" != "quay.io" ]]; then
# quay.rdoproject.io doesn't support filter_tag_name, so increase limit to 100
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tag/?limit=100 | jq -r .tags[].name | sort -u | grep $REF)
else
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tag/?onlyActiveTags=true\&filter_tag_name=like:$REF | jq -r .tags[].name)
fi
Expand Down
Loading