Skip to content

Commit 76c0369

Browse files
fix(hack): make promote-retag ref_repo port-safe
Address review feedback from gemini-code-assist on hack/promote-retag.sh:48: ref_repo now strips the :tag from the last path component only, so a registry host carrying a :port (e.g. localhost:5000/cozystack/operator) on a no-tag ref is preserved instead of truncated to the host. Assisted-By: Claude <[email protected]> Signed-off-by: Myasnikov Daniil <[email protected]>
1 parent f2f54dc commit 76c0369

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎hack/promote-retag.sh‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
# expected to be the rc's digest-vendored tree (the release-X.Y.Z-rc.N staging
1616
# branch). Requires: yq (mikefarah), skopeo, and a registry login already done.
1717
#
18-
# Registry-host assumption: the registry host carries no :port (true for the
19-
# current iad.ocir.io / ghcr.io registries), so the only ':' in a "repo:tag"
20-
# ref is the tag separator. Revisit the repo/tag split below if that changes.
18+
# The repo/tag split (ref_repo below) strips the :tag from the last path
19+
# component only, so registry hosts that carry a :port are preserved.
2120
set -eu
2221

2322
STABLE="${1:?usage: promote-retag.sh <stable-version> [--dry-run]}"
@@ -45,7 +44,18 @@ collect_refs() {
4544
}
4645

4746
# Split a "<repo>[:<tag>]@sha256:<digest>" ref into repo and digest.
48-
ref_repo() { r="${1%@*}"; printf '%s' "${r%:*}"; } # strip @digest, then :tag
47+
# ref_repo strips the :tag from the LAST path component only, so a registry
48+
# host that carries a :port (e.g. localhost:5000/cozystack/operator, with no
49+
# tag) keeps its port instead of being truncated to the host.
50+
ref_repo() {
51+
r="${1%@*}" # strip @digest
52+
img="${r##*/}" # last path component (may carry :tag)
53+
if [ "$r" = "$img" ]; then
54+
printf '%s' "${img%:*}"
55+
else
56+
printf '%s/%s' "${r%/*}" "${img%:*}"
57+
fi
58+
}
4959
ref_digest() { printf '%s' "${1##*@}"; } # sha256:...
5060

5161
copy() {

0 commit comments

Comments
 (0)