Skip to content

Commit 7861454

Browse files
ctl: Transform to not dump to JSON string if the return of the transform is text. (#283)
* ctl: Transform to not dump to JSON string if the return of the transform is text.
1 parent 3870abe commit 7861454

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Allows the `infrahubctl transform` to return a regular string that does not get converted to a JSON string.

infrahub_sdk/ctl/cli_commands.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,11 @@ def transform(
352352
# Run Transform
353353
result = asyncio.run(transform.run(data=data))
354354

355-
json_string = ujson.dumps(result, indent=2, sort_keys=True)
355+
if isinstance(result, str):
356+
json_string = result
357+
else:
358+
json_string = ujson.dumps(result, indent=2, sort_keys=True)
359+
356360
if out:
357361
write_to_file(Path(out), json_string)
358362
else:

0 commit comments

Comments
 (0)