Skip to content

Commit 8c3b9cb

Browse files
committed
pin-bundle-images: resolve fork tags from Quay under local registry CI
When LOCAL_REGISTRY=1 and the go.mod module path is not under openstack-k8s-operators, keep bundle pullspecs on IMAGEREGISTRY but query Quay for bundle tag digests. Upstream modules still use the local registry v2 tags/list path when mirrored. Signed-off-by: Amartya Sinha <amsinha@redhat.com>
1 parent e795160 commit 8c3b9cb

1 file changed

Lines changed: 17 additions & 9 deletions

File tree

hack/pin-bundle-images.sh

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,24 +46,32 @@ for MOD_PATH in ${MOD_PATHS}; do
4646
if [[ "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ]]; then
4747
if [[ "$IMAGENAMESPACE" != "openstack-k8s-operators" || "${IMAGEREGISTRY}" != "quay.io" ]]; then
4848
REPO_URL="${IMAGEREGISTRY}/${IMAGENAMESPACE}"
49-
CURL_REGISTRY="${IMAGEREGISTRY}"
50-
# Quay registry v2 api does not return all the tags that's why keeping v1 for quay and v2
51-
# for local registry
5249
if [[ ${LOCAL_REGISTRY} -eq 1 ]]; then
53-
REPO_CURL_URL="http://${CURL_REGISTRY}/v2/${IMAGENAMESPACE}"
54-
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
55-
# replace docker.io by hub.docker.com to read tags
56-
REPO_CURL_URL="https://hub.docker.com/v2/repositories/${IMAGENAMESPACE}"
50+
# Pullspecs use the local registry. Tag source: local v2 when upstream bundles are mirrored
51+
# locally; Quay v1 only for forks (module path not under openstack-k8s-operators), where tags
52+
# typically are not on the ephemeral registry.
53+
if [[ "$GITHUB_USER" != "openstack-k8s-operators" ]]; then
54+
CURL_REGISTRY="quay.io"
55+
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
56+
else
57+
CURL_REGISTRY="${IMAGEREGISTRY}"
58+
REPO_CURL_URL="http://${CURL_REGISTRY}/v2/${IMAGENAMESPACE}"
59+
fi
5760
else
58-
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
61+
CURL_REGISTRY="${IMAGEREGISTRY}"
62+
if [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
63+
REPO_CURL_URL="https://hub.docker.com/v2/repositories/${IMAGENAMESPACE}"
64+
else
65+
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
66+
fi
5967
fi
6068
else
6169
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
6270
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
6371
fi
6472
fi
6573

66-
if [[ ${LOCAL_REGISTRY} -eq 1 && ( "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
74+
if [[ ${LOCAL_REGISTRY} -eq 1 && "${CURL_REGISTRY}" != "quay.io" && ( "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
6775
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/list | jq -r '.tags // [] | .[]' | sort -u | { grep $REF || true; })
6876
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
6977
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/?page_size=100 | jq -r '.results // [] | .[].name' | sort -u | { grep $REF || true; })

0 commit comments

Comments
 (0)