From 39985be3fc46973011702febabe9169f49514dd7 Mon Sep 17 00:00:00 2001 From: Mikhail Yohman Date: Mon, 24 Feb 2025 08:51:26 -0700 Subject: [PATCH 1/2] ctl: Transform to not dump to JSON string if the return of the transform is text. --- infrahub_sdk/ctl/cli_commands.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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: From 43eecbda6ab8ef2bff0d5a9a9140a166aa72483d Mon Sep 17 00:00:00 2001 From: Mikhail Yohman Date: Tue, 25 Feb 2025 07:14:06 -0700 Subject: [PATCH 2/2] Add changelog. --- changelog/+ctl-transform-return-string.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/+ctl-transform-return-string.md 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