From 79b192e736791da40f0fcf4d0df31d309e9baaa1 Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Fri, 15 Jan 2021 18:19:24 +0100 Subject: [PATCH] inputs: add new org.osbuild.tree input This represents the tree-type input, which is the simplest form of input a stage can consume. For the stage it is just a file system tree at a specific location and the contents itself is mostly opaque. An obvious thing to do with such a content is carbon copy it to a different location. Currently this input only supports the pipelines as origins, which are identified via their id. --- inputs/org.osbuild.tree | 58 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100755 inputs/org.osbuild.tree diff --git a/inputs/org.osbuild.tree b/inputs/org.osbuild.tree new file mode 100755 index 00000000..69999c50 --- /dev/null +++ b/inputs/org.osbuild.tree @@ -0,0 +1,58 @@ +#!/usr/bin/python3 +""" +Tree inputs + +Resolve the given pipeline `id` to a path and return that. If +`id` is `null` or the empty string it returns an empty tree. +""" + + +import json +import sys + +from osbuild.objectstore import StoreClient + + +SCHEMA = """ +"additionalProperties": false, +"required": ["pipeline"], +"properties": { + "pipeline": { + "description": "The Pipeline that built the desired tree", + "type": "object", + "required": ["id"], + "additionalProperties": false, + "properties": { + "id": { + "description": "Identifier for the pipeline", + "type": "string" + } + } + } +} +""" + + +def main(): + args = json.load(sys.stdin) + options = args["options"] + + store = StoreClient(connect_to=args["api"]["store"]) + pid = options["pipeline"]["id"] + + if not pid: + path = store.mkdtemp(prefix="empty") + else: + path = store.read_tree(pid) + + if not path: + json.dump({"error": "Could find target"}, sys.stdout) + return 1 + + json.dump({"path": path}, sys.stdout) + return 0 + + +if __name__ == '__main__': + r = main() + sys.exit(r)