Skip to content

Commit 213f805

Browse files
committed
Improve pin-bundle-images.sh to handle different fork names
BASE was derived from Replace.Path, so a fork named sdatko/openstack-k8s-operators-telemetry-operator gave BASE "openstack-k8s-operators-telemetry" instead of "telemetry", querying a non-existent bundle repo on quay.rdoproject.org and failing the telemetry-operator-build-deploy-kuttl prow job. Derive BASE from the original module Path so the bundle lookup depends on the PR target, not the fork name. Use Replace.Path only for GITHUB_USER/GIT_REPO where the fork identity matters. Modules replaced with a local directory (./api, ../foo) are skipped like the old "./apis" check did, and Main modules are excluded explicitly. Signed-off-by: Daniel Pawlik <dpawlik@redhat.com>
1 parent be32086 commit 213f805

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

‎hack/pin-bundle-images.sh‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ if [ -n "$DOCKERFILE" ]; then
1717
fi
1818

1919
#loop over each openstack-k8s-operators go.mod entry
20-
MOD_PATHS=$(go list -mod=readonly -m -json all | jq -r '. | select(.Path | contains("openstack")) | select(.Path | contains("openstack-operator") | not) | select(.Path | contains("lib-common") | not) | .Replace // . |.Path')
20+
MOD_PATHS=$(go list -mod=readonly -m -json all | jq -r '. | select(.Main != true) | select(.Path | contains("openstack")) | select(.Path | contains("openstack-operator") | not) | select(.Path | contains("lib-common") | not) | .Path')
2121
for MOD_PATH in ${MOD_PATHS}; do
2222
if [[ "$MOD_PATH" == "./apis" ]]; then
2323
continue
2424
fi
25-
MOD_VERSION=$(go list -mod=readonly -m -json all | jq -r ". | select(.Path | contains(\"openstack\")) | .Replace // . | select( .Path == \"$MOD_PATH\") | .Version")
25+
MOD_JSON=$(go list -mod=readonly -m -json "$MOD_PATH")
26+
MOD_VERSION=$(echo "$MOD_JSON" | jq -r '.Replace.Version // .Version')
27+
REPL_PATH=$(echo "$MOD_JSON" | jq -r '.Replace.Path // empty')
28+
if [[ "$REPL_PATH" == /* || "$REPL_PATH" == ./* || "$REPL_PATH" == ../* ]]; then
29+
continue
30+
fi
2631

2732
BASE=$(echo $MOD_PATH | sed -e 's|github.com/.*/\(.*\)-operator/.*|\1|')
2833

29-
GIT_REPO=${MOD_PATH%"/apis"}
34+
EFFECTIVE_PATH=${REPL_PATH:-$MOD_PATH}
35+
GIT_REPO=${EFFECTIVE_PATH%"/apis"}
3036
GIT_REPO=${GIT_REPO%"/api"}
3137

3238
# Check if there is a custom tag for IMAGEBASE operator
@@ -39,7 +45,8 @@ for MOD_PATH in ${MOD_PATHS}; do
3945
fi
4046
fi
4147

42-
GITHUB_USER=$(echo $MOD_PATH | sed -e 's|github.com/\(.*\)/.*-operator/.*$|\1|')
48+
GITHUB_USER=${EFFECTIVE_PATH#github.com/}
49+
GITHUB_USER=${GITHUB_USER%%/*}
4350
CURL_REGISTRY="quay.io"
4451
REPO_CURL_URL="https://${CURL_REGISTRY}/api/v1/repository/openstack-k8s-operators"
4552
REPO_URL="${CURL_REGISTRY}/openstack-k8s-operators"

0 commit comments

Comments
 (0)