assemblers: add org.osbuild.error

This is, like the stage with the same name, an assembler that
will exit with an error code (default 255, but can be specified
via the assembler options). It is mostly useful for testing.
This commit is contained in:
Christian Kellner 2021-03-09 16:26:42 +00:00 committed by Tom Gundersen
parent d98f460841
commit 72ffa50c45

36
assemblers/org.osbuild.error Executable file
View file

@ -0,0 +1,36 @@
#!/usr/bin/python3
"""
Return an error
Error assembler. Return the given error. Very much like the error stage this
is useful for testing, debugging, and wasting time.
"""
import sys
import osbuild.api
SCHEMA = """
"additionalProperties": false,
"properties": {
"returncode": {
"description": "What to return code to use",
"type": "number",
"default": 255
}
}
"""
def main(options):
errno = options.get("returncode", 255)
print(f"Error assembler will now return error: {errno}")
return errno
if __name__ == '__main__':
args = osbuild.api.arguments()
r = main(args.get("options", {}))
sys.exit(r)