Skip to content

Commit

Permalink
Merge pull request #172 from seqeralabs/fix-overwrite-to-json
Browse files Browse the repository at this point in the history
fix: handling for overwrite class without json output
  • Loading branch information
ejseqera authored Dec 3, 2024
2 parents cc03184 + 6dab61c commit d6424f9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
12 changes: 10 additions & 2 deletions seqerakit/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,16 @@ def __init__(self, sp, list_for_add_method):
"""
self.sp = sp
self.list_for_add_method = list_for_add_method
# Create an instance of Overwrite class
self.overwrite_method = overwrite.Overwrite(self.sp)

# Create a separate instance of the Seqera Platform client without JSON output
# This is needed because when checking if resources exist during overwrite operations,
# we don't want JSON output mixed with the actual resource creation output
sp_without_json = seqeraplatform.SeqeraPlatform(
cli_args=sp.cli_args,
dryrun=sp.dryrun,
json=False,
)
self.overwrite_method = overwrite.Overwrite(sp_without_json)

def handle_block(self, block, args, destroy=False, dryrun=False):
# Check if delete is set to True, and call delete handler
Expand Down
6 changes: 4 additions & 2 deletions seqerakit/seqeraplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,12 @@ def _execute_command(self, full_cmd, to_json=False, print_stdout=True):

if self.json or to_json:
out = json.loads(stdout)
print(json.dumps(out))
if should_print:
print(json.dumps(out))
else:
out = stdout
print(stdout)
if should_print:
print(stdout)

return out

Expand Down

0 comments on commit d6424f9

Please sign in to comment.