inputs/ostree: support pipeline inputs

In addition to pulling ostree commits via sources, the input
now supports pulling commits that were built via an osbuild
pipeline.
This commit is contained in:
Christian Kellner 2021-02-11 12:04:50 +00:00
parent 34186daa4e
commit 7caa263659

View file

@ -30,7 +30,7 @@ SCHEMA = """
"origin": {
"description": "The origin of the input (must be 'org.osbuild.source')",
"type": "string",
"enum": ["org.osbuild.source"]
"enum": ["org.osbuild.source", "org.osbuild.pipeline"]
},
"references": {
"description": "Commit identifier",
@ -111,11 +111,17 @@ def main():
source = store.source("org.osbuild.files")
output = store.mkdtemp(prefix="files-output")
# input verification must have happened via schema
# validation to ensure that `origin` is a source
source = store.source("org.osbuild.ostree")
if origin == "org.osbuild.pipeline":
for ref, options in refs.items():
source = store.read_tree(ref)
with open(os.path.join(source, "compose.json"), "r") as f:
compose = json.load(f)
commit_id = compose["ostree-commit"]
export({commit_id: options}, source, output)
else:
source = store.source("org.osbuild.ostree")
export(refs, source, output)
export(refs, source, output)
return 0