Skip to content

Commit 037d265

Browse files
stuggiclaude
andcommitted
Fix pin-bundle-images.sh IMAGENAMESPACE behavior
Revert IMAGENAMESPACE behavior to pre-507cdb80 logic where it only affects replaced operators (non-openstack-k8s-operators) and operators matching IMAGEBASE. Standard openstack-k8s-operators bundles now always use quay.io/openstack-k8s-operators regardless of IMAGENAMESPACE. This fixes the issue where setting IMAGENAMESPACE to a custom value would try to find all bundles (barbican, cinder, etc.) in the custom namespace instead of quay.io/openstack-k8s-operators, causing failures when those bundles don't exist there. The previous behavior is restored: - IMAGENAMESPACE only affects replaced operators (e.g., custom forks) - IMAGEBASE explicitly targets a specific operator for custom namespace - Standard operators always use openstack-k8s-operators namespace All bug fixes from 507cdb8 are retained (better error handling, jq safety checks, proper query string syntax). Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Signed-off-by: Martin Schuppert <mschuppert@redhat.com>
1 parent 499ed00 commit 037d265

1 file changed

Lines changed: 17 additions & 46 deletions

File tree

hack/pin-bundle-images.sh

Lines changed: 17 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -43,62 +43,33 @@ for MOD_PATH in ${MOD_PATHS}; do
4343
CURL_REGISTRY="quay.io"
4444
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/openstack-k8s-operators"
4545
REPO_URL="${CURL_REGISTRY}/openstack-k8s-operators"
46-
47-
# IMAGEBASE takes precedence - if this operator matches IMAGEBASE, use custom registry
48-
if [[ "$BASE" == "$IMAGEBASE" ]]; then
49-
REPO_URL="${IMAGEREGISTRY}/${IMAGENAMESPACE}"
50-
CURL_REGISTRY="${IMAGEREGISTRY}"
51-
if [[ ${LOCAL_REGISTRY} -eq 1 ]]; then
52-
REPO_CURL_URL="http://${CURL_REGISTRY}/v2/${IMAGENAMESPACE}"
53-
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
54-
REPO_CURL_URL="https://hub.docker.com/v2/repositories/${IMAGENAMESPACE}"
55-
else
56-
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
57-
fi
58-
# For operators with replace directives (non-openstack-k8s-operators users),
59-
# bundle images are only on quay.io, not mirrored to local registry
60-
elif [[ "$GITHUB_USER" != "openstack-k8s-operators" ]]; then
61-
# Force quay.io for replaced operators, use the GitHub user's namespace
62-
CURL_REGISTRY="quay.io"
63-
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
64-
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
65-
# For standard operators with custom registry settings
66-
elif [[ "$IMAGENAMESPACE" != "openstack-k8s-operators" || "${IMAGEREGISTRY}" != "quay.io" ]]; then
67-
REPO_URL="${IMAGEREGISTRY}/${IMAGENAMESPACE}"
68-
CURL_REGISTRY="${IMAGEREGISTRY}"
69-
# Quay registry v2 api does not return all the tags that's why keeping v1 for quay and v2
70-
# for local registry
71-
if [[ ${LOCAL_REGISTRY} -eq 1 ]]; then
72-
REPO_CURL_URL="http://${CURL_REGISTRY}/v2/${IMAGENAMESPACE}"
73-
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
74-
# replace docker.io by hub.docker.com to read tags
75-
REPO_CURL_URL="https://hub.docker.com/v2/repositories/${IMAGENAMESPACE}"
46+
if [[ "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ]]; then
47+
if [[ "$IMAGENAMESPACE" != "openstack-k8s-operators" || "${IMAGEREGISTRY}" != "quay.io" ]]; then
48+
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
52+
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}"
57+
else
58+
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
59+
fi
7660
else
77-
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
61+
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
62+
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
7863
fi
7964
fi
8065

81-
# Query local registry only for standard operators (openstack-k8s-operators) or custom IMAGEBASE
82-
# Replaced operators (e.g., lmiccini/*) always query quay.io since bundles aren't mirrored locally
83-
if [[ ${LOCAL_REGISTRY} -eq 1 && ( "$GITHUB_USER" == "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
66+
if [[ ${LOCAL_REGISTRY} -eq 1 && ( "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
8467
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/list | jq -r '.tags // [] | .[]' | sort -u | { grep $REF || true; })
85-
# If local registry doesn't have the bundle, fall back to quay.io
86-
if [ -z "$SHA" ]; then
87-
SHA=$(curl -s https://quay.io/api/v1/repository/openstack-k8s-operators/$BASE-operator-bundle/tag/?onlyActiveTags=true\&filter_tag_name=like:$REF | jq -r '.tags // [] | .[].name')
88-
# Update REPO_URL to use quay.io since we're falling back
89-
REPO_URL="quay.io/openstack-k8s-operators"
90-
fi
9168
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
9269
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/?page_size=100 | jq -r '.results // [] | .[].name' | sort -u | { grep $REF || true; })
9370
elif [[ "${CURL_REGISTRY}" != "quay.io" ]]; then
9471
# quay.rdoproject.io doesn't support filter_tag_name, so increase limit to 100
9572
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tag/?onlyActiveTags=true\&limit=100 | jq -r '.tags // [] | .[].name' | sort -u | { grep $REF || true; })
96-
# If non-quay.io registry doesn't have the bundle for openstack-k8s-operators, fall back to quay.io
97-
if [[ -z "$SHA" && "$GITHUB_USER" == "openstack-k8s-operators" ]]; then
98-
SHA=$(curl -s https://quay.io/api/v1/repository/openstack-k8s-operators/$BASE-operator-bundle/tag/?onlyActiveTags=true\&filter_tag_name=like:$REF | jq -r '.tags // [] | .[].name')
99-
# Update REPO_URL to use quay.io since we're falling back
100-
REPO_URL="quay.io/openstack-k8s-operators"
101-
fi
10273
else
10374
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tag/?onlyActiveTags=true\&filter_tag_name=like:$REF | jq -r '.tags // [] | .[].name')
10475
fi

0 commit comments

Comments
 (0)