Skip to content

Commit 89a5f5d

Browse files
committed
tools: add gen-manifest helper
Add a `gen-manifests` helper that creates mock manifests from the given image type. Its not perfect mocks as it still will look into the bootc ref (centos9). Its not generating checksums only because to compare from the manifests generated by bib and images its easier to work with full manifests and we only have very few of them in bib.
1 parent 3f51f01 commit 89a5f5d

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

tools/gen-manifests

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/bash
2+
#
3+
# Generates mock manifests (i.e. without real resolved content)
4+
# XXX: copied from the images library, this is temporary until
5+
# all image manifest generation for bib moves into "images" itself.
6+
7+
set -euo pipefail
8+
9+
tmpdir="$(mktemp -d)"
10+
cleanup() {
11+
rm -r "${tmpdir}"
12+
}
13+
trap cleanup EXIT
14+
15+
manifests_dir="${1:-test/data/manifests}"
16+
# XXX: we look into the image so we need a real bootc container
17+
# available, this is not ideal
18+
bootc_ref="${2:-quay.io/centos-bootc/centos-bootc:stream9}"
19+
refp=$(echo $bootc_ref | sed s#/#_#g)
20+
21+
if [ "$manifests_dir" = "" ]; then
22+
echo "need a manifests dir as first argument"
23+
exit 1
24+
fi
25+
mkdir -p "$manifests_dir"
26+
27+
export OSBUILD_TESTING_RNG_SEED=0
28+
export IMAGE_BUILDER_EXPERIMENTAL=bib-mock-resolvers
29+
30+
echo "Checking if bib compiles"
31+
if ! (cd bib && go build -v -o "${tmpdir}/bin/" ./cmd/bootc-image-builder); then
32+
echo "Failed to compile bootc-image-builder. Skipping..."
33+
exit 0
34+
fi
35+
36+
echo "Generating mock manifests"
37+
podman pull "$bootc_ref"
38+
# xxx: more arches?
39+
for arch in x86_64 aarch64; do
40+
# XXX: add anaconda-iso once we can mock it too
41+
for imgtype in ami qcow2 vmdk raw vhd gce; do
42+
if ! "${tmpdir}/bin/bootc-image-builder" \
43+
manifest -v "$bootc_ref" \
44+
--target-arch "$arch" \
45+
--type "$imgtype" \
46+
2> "${tmpdir}/stderr" \
47+
| jq > "$manifests_dir/manifest-$refp-$arch-$imgtype.json"; then
48+
cat "${tmpdir}/stderr"
49+
exit 1
50+
fi
51+
done
52+
done
53+
54+
echo "Manifests saved to ${manifests_dir}"

0 commit comments

Comments
 (0)