Skip to content

Commit 92d8fcf

Browse files
lmicciniclaude
andcommitted
Fix pin-bundle-images.sh for operators with replace directives
When using LOCAL_REGISTRY=1 with operator replace directives pointing to personal forks (e.g., lmiccini/*), the script was trying to query the local registry for bundle images that don't exist there, causing curl to return null and jq to fail with "Cannot iterate over null (null)". Root cause: Bundle images from personal forks are only published to quay.io in the user's namespace (e.g., quay.io/lmiccini/glance-operator-bundle) and are NOT mirrored to the local CI registry. The local registry only contains standard openstack-k8s-operators bundles. The fix: 1. Check IMAGEBASE first (takes precedence for custom registry settings) 2. For replaced operators (GITHUB_USER != "openstack-k8s-operators"): - Always query quay.io with the user's namespace - Skip local registry entirely 3. For standard operators: use local registry when LOCAL_REGISTRY=1 4. Update curl logic to only query local registry for standard operators This allows CI builds with depends-on to work correctly when the dependency uses replace directives for operator APIs. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 1cba828 commit 92d8fcf

1 file changed

Lines changed: 34 additions & 17 deletions

File tree

‎hack/pin-bundle-images.sh‎

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,44 @@ 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-
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="${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
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="${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="${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}"
6076
else
61-
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${GITHUB_USER}"
62-
REPO_URL="${CURL_REGISTRY}/${GITHUB_USER}"
77+
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/${IMAGENAMESPACE}"
6378
fi
6479
fi
6580

66-
if [[ ${LOCAL_REGISTRY} -eq 1 && ( "$GITHUB_USER" != "openstack-k8s-operators" || "$BASE" == "$IMAGEBASE" ) ]]; then
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
6784
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/list | jq -r .tags[] | sort -u | grep $REF)
6885
elif [[ "${CURL_REGISTRY}" == "docker.io" ]]; then
6986
SHA=$(curl -s ${REPO_CURL_URL}/$BASE-operator-bundle/tags/?page_size=100 | jq -r .results[].name | sort -u | grep $REF)

0 commit comments

Comments
 (0)