tools/osbuild-mpp: resolve manifest lists

Add support for resolving manifest lists in osbuild-mpp.
Adds an `index` boolean field to the container image struct for
mpp-resolve-images.  When enabled, the preprocessor will also store the
manifest-list digest as a separate skopeo-index source and add it to the
skopeo stage under the `manifest-lists` input.
This commit is contained in:
Achilleas Koutsou 2023-03-27 18:14:50 +02:00 committed by Ondřej Budai
parent ac2f140d4c
commit 3e94088e1f

View file

@ -1495,12 +1495,14 @@ class ManifestFileV2(ManifestFile):
return
refs = element_enter(inputs_images, "references", {})
manifest_lists = []
for image in element_enter(mpp, "images", []):
source = image["source"]
name = image.get("name", source)
digest = image.get("digest", None)
tag = image.get("tag", None)
index = image.get("index", False)
main_manifest = ImageManifest.load(source, tag=tag, digest=digest)
@ -1529,6 +1531,23 @@ class ManifestFileV2(ManifestFile):
"name": name
}
if index:
manifest_lists.append(main_manifest.digest)
container_index_source = element_enter(self.sources, "org.osbuild.skopeo-index", {})
index_items = element_enter(container_index_source, "items", {})
index_items[main_manifest.digest] = {
"image": {
"name": source
}
}
# if we collected manifest lists, create the manifest-lists input array for the stage
if manifest_lists:
inputs_manifests = element_enter(inputs, "manifest-lists", {})
inputs_manifests["type"] = "org.osbuild.files"
inputs_manifests["origin"] = "org.osbuild.source"
inputs_manifests["references"] = manifest_lists
def main():
parser = argparse.ArgumentParser(description="Manifest pre processor")