diff --git a/changelog/+ctl-transform-return-string.md b/changelog/+ctl-transform-return-string.md new file mode 100644 index 00000000..4c9ea917 --- /dev/null +++ b/changelog/+ctl-transform-return-string.md @@ -0,0 +1 @@ +Allows the `infrahubctl transform` to return a regular string that does not get converted to a JSON string. \ No newline at end of file diff --git a/infrahub_sdk/ctl/cli_commands.py b/infrahub_sdk/ctl/cli_commands.py index 7a10f136..633ccd2c 100644 --- a/infrahub_sdk/ctl/cli_commands.py +++ b/infrahub_sdk/ctl/cli_commands.py @@ -352,7 +352,11 @@ def transform( # Run Transform result = asyncio.run(transform.run(data=data)) - json_string = ujson.dumps(result, indent=2, sort_keys=True) + if isinstance(result, str): + json_string = result + else: + json_string = ujson.dumps(result, indent=2, sort_keys=True) + if out: write_to_file(Path(out), json_string) else: