From 6333d1c3bdaf84fee8268fd92572f2fc22a4675a Mon Sep 17 00:00:00 2001 From: Christian Kellner Date: Tue, 17 Dec 2019 12:32:03 +0100 Subject: [PATCH] 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. --- stages/org.osbuild.error | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 stages/org.osbuild.error diff --git a/stages/org.osbuild.error b/stages/org.osbuild.error new file mode 100755 index 00000000..51c8b9fe --- /dev/null +++ b/stages/org.osbuild.error @@ -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)