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.
This commit is contained in:
parent
7084c2a600
commit
79b192e736
1 changed files with 58 additions and 0 deletions
58
inputs/org.osbuild.tree
Executable file
58
inputs/org.osbuild.tree
Executable file
|
|
@ -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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue