@@ -19,7 +19,25 @@ need_cmd sha256sum
1919
2020python3 -m py_compile " ${ROOT} /scripts/render-catalog-rows.py"
2121
22- python3 - << 'PY ' "${ROOT}/catalog/catalog.json" "${ROOT}/catalog/image-sources.json" "${ROOT}/catalog/profile.env"
22+ WORK_ROOT=" ${TMP_ROOT} /template-copy"
23+ mkdir -p " ${WORK_ROOT} "
24+ cp -R " ${ROOT} /catalog" " ${WORK_ROOT} /catalog"
25+ cp -R " ${ROOT} /scripts" " ${WORK_ROOT} /scripts"
26+
27+ python3 - << 'PY ' "${WORK_ROOT}/catalog/image-sources.json"
28+ import json
29+ import sys
30+ from pathlib import Path
31+
32+ path = Path(sys.argv[1])
33+ payload = json.loads(path.read_text(encoding="utf-8"))
34+ for entry in payload.get("images", []):
35+ name = str(entry["name"])
36+ entry["ref"] = f"ghcr.io/example-org/example-apps/{name}@sha256:" + ("1" * 64)
37+ path.write_text(json.dumps(payload, indent=2, sort_keys=True) + "\n", encoding="utf-8")
38+ PY
39+
40+ python3 - << 'PY ' "${WORK_ROOT}/catalog/catalog.json" "${WORK_ROOT}/catalog/image-sources.json" "${WORK_ROOT}/catalog/profile.env"
2341import json
2442import re
2543import sys
100118
101119export OURBOX_PLATFORM_CONTRACT_DIGEST=" sha256:0000000000000000000000000000000000000000000000000000000000000000"
102120
103- bash " ${ROOT } /scripts/render-catalog-bundle.sh"
121+ bash " ${WORK_ROOT } /scripts/render-catalog-bundle.sh"
104122
105- test -f " ${ROOT } /dist/application-catalog-bundle.tar.gz"
106- test -f " ${ROOT } /dist/application-catalog-bundle.tar.gz.sha256"
107- test -f " ${ROOT } /dist/images.lock.json"
123+ test -f " ${WORK_ROOT } /dist/application-catalog-bundle.tar.gz"
124+ test -f " ${WORK_ROOT } /dist/application-catalog-bundle.tar.gz.sha256"
125+ test -f " ${WORK_ROOT } /dist/images.lock.json"
108126
109- expected_sha=" $( awk ' NF>=1 {print $1; exit}' " ${ROOT } /dist/application-catalog-bundle.tar.gz.sha256" ) "
110- actual_sha=" $( sha256sum " ${ROOT } /dist/application-catalog-bundle.tar.gz" | awk ' {print $1}' ) "
127+ expected_sha=" $( awk ' NF>=1 {print $1; exit}' " ${WORK_ROOT } /dist/application-catalog-bundle.tar.gz.sha256" ) "
128+ actual_sha=" $( sha256sum " ${WORK_ROOT } /dist/application-catalog-bundle.tar.gz" | awk ' {print $1}' ) "
111129[[ " ${expected_sha} " == " ${actual_sha} " ]] || {
112130 echo " bundle sha mismatch" >&2
113131 exit 1
114132}
115133
116134mkdir -p " ${TMP_ROOT} /extract"
117- tar -xzf " ${ROOT } /dist/application-catalog-bundle.tar.gz" -C " ${TMP_ROOT} /extract"
118- cmp -s " ${ROOT } /catalog/catalog.json" " ${TMP_ROOT} /extract/catalog.json"
119- cmp -s " ${ROOT } /dist/images.lock.json" " ${TMP_ROOT} /extract/images.lock.json"
120- cmp -s " ${ROOT } /catalog/profile.env" " ${TMP_ROOT} /extract/profile.env"
135+ tar -xzf " ${WORK_ROOT } /dist/application-catalog-bundle.tar.gz" -C " ${TMP_ROOT} /extract"
136+ cmp -s " ${WORK_ROOT } /catalog/catalog.json" " ${TMP_ROOT} /extract/catalog.json"
137+ cmp -s " ${WORK_ROOT } /dist/images.lock.json" " ${TMP_ROOT} /extract/images.lock.json"
138+ cmp -s " ${WORK_ROOT } /catalog/profile.env" " ${TMP_ROOT} /extract/profile.env"
121139
122140python3 - << 'PY ' \
123141 "${TMP_ROOT}/extract/manifest.env" \
124142 "${TMP_ROOT}/extract/profile.env" \
125- "${ROOT }/catalog/catalog.json" \
126- "${ROOT }/catalog/image-sources.json" \
127- "${ROOT }/dist/images.lock.json"
143+ "${WORK_ROOT }/catalog/catalog.json" \
144+ "${WORK_ROOT }/catalog/image-sources.json" \
145+ "${WORK_ROOT }/dist/images.lock.json"
128146import json
129147import os
130148import re
@@ -183,10 +201,10 @@ for image in images_lock["images"]:
183201 raise SystemExit(f"generated image lock used_by mismatch for {image['name']}")
184202PY
185203
186- python3 " ${ROOT } /scripts/render-catalog-rows.py" \
187- --catalog-json " ${ROOT } /catalog/catalog.json" \
188- --profile-env " ${ROOT } /catalog/profile.env" \
189- --images-lock " ${ROOT } /dist/images.lock.json" \
204+ python3 " ${WORK_ROOT } /scripts/render-catalog-rows.py" \
205+ --catalog-json " ${WORK_ROOT } /catalog/catalog.json" \
206+ --profile-env " ${WORK_ROOT } /catalog/profile.env" \
207+ --images-lock " ${WORK_ROOT } /dist/images.lock.json" \
190208 --out-catalog " ${TMP_ROOT} /catalog.tsv" \
191209 --channel stable \
192210 --tag " sha-test-run-1" \
@@ -195,10 +213,11 @@ python3 "${ROOT}/scripts/render-catalog-rows.py" \
195213 --revision " deadbeefcafedeadbeefcafedeadbeefcafedead" \
196214 --arch amd64 \
197215 --artifact-digest " sha256:1111111111111111111111111111111111111111111111111111111111111111" \
198- --pinned-ref " ghcr.io/example/sw-ourbox-catalog-hello-world @sha256:1111111111111111111111111111111111111111111111111111111111111111"
216+ --pinned-ref " ghcr.io/example/sw-ourbox-catalog-example @sha256:1111111111111111111111111111111111111111111111111111111111111111"
199217
200- python3 - << 'PY ' "${TMP_ROOT}/catalog.tsv"
218+ python3 - << 'PY ' "${TMP_ROOT}/catalog.tsv" "${WORK_ROOT}/catalog/profile.env" "${WORK_ROOT}/catalog/catalog.json"
201219import csv
220+ import json
202221import os
203222import sys
204223from pathlib import Path
@@ -207,6 +226,14 @@ rows = list(csv.DictReader(Path(sys.argv[1]).open("r", encoding="utf-8"), delimi
207226if len(rows) != 1:
208227 raise SystemExit(f"expected one rendered catalog row, got {len(rows)}")
209228row = rows[0]
229+ profile = {}
230+ for raw_line in Path(sys.argv[2]).read_text(encoding="utf-8").splitlines():
231+ line = raw_line.strip()
232+ if not line or line.startswith("#"):
233+ continue
234+ key, value = line.split("=", 1)
235+ profile[key] = value
236+ catalog = json.loads(Path(sys.argv[3]).read_text(encoding="utf-8"))
210237expected = {
211238 "channel": "stable",
212239 "tag": "sha-test-run-1",
@@ -215,9 +242,9 @@ expected = {
215242 "revision": "deadbeefcafedeadbeefcafedeadbeefcafedead",
216243 "arch": "amd64",
217244 "platform_contract_digest": os.environ["OURBOX_PLATFORM_CONTRACT_DIGEST"],
218- "platform_profile": "hello-world" ,
245+ "platform_profile": catalog["catalog_id"] ,
219246 "artifact_digest": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
220- "pinned_ref": "ghcr.io/example/sw-ourbox-catalog-hello-world @sha256:1111111111111111111111111111111111111111111111111111111111111111",
247+ "pinned_ref": "ghcr.io/example/sw-ourbox-catalog-example @sha256:1111111111111111111111111111111111111111111111111111111111111111",
221248}
222249for key, expected_value in expected.items():
223250 if row.get(key) != expected_value:
0 commit comments