stage/error: new simple stage always erroring out

A simple stage like 'noop' that will return with `returncode` or
255 if nothing is specified. Like 'noop' it might be useful for
testing, debugging, and wasting time.
This commit is contained in:
Christian Kellner 2019-12-17 12:32:03 +01:00 committed by Lars Karlitski
parent ede3f6baeb
commit 6333d1c3bd

31
stages/org.osbuild.error Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/python3
import json
import sys
STAGE_DESC = "Return an error"
STAGE_INFO = """
Error stage. Return the given error. Useful for testing, debugging, and
wasting time.
"""
STAGE_OPTS = """
"properties": {
"returncode": {
"description": "What to return code to use"
"type": "number",
"default": 255
}
}
"""
def main(_tree, options):
errno = options.get("returncode", 255)
print(f"Error stage will now return error: {errno}")
return errno
if __name__ == '__main__':
args = json.load(sys.stdin)
r = main(args["tree"], args.get("options", {}))
sys.exit(r)