Update st2client/st2client/commands/action.py to deduplicate `self.manager.clone`
@@ -348,6 +348,8 @@ class ActionCloneCommand(resource.ContentPackResourceCloneCommand):
except ResourceNotFoundError:
dest_instance = None
+ overwrite = False
+
if dest_instance:
user_input = ""
if not args.force:
@@ -355,22 +357,16 @@ class ActionCloneCommand(resource.ContentPackResourceCloneCommand):
"The destination action already exists. Do you want to overwrite? (y/n): "
)
if args.force or user_input.lower() == "y" or user_input.lower() == "yes":
- return self.manager.clone(
- source_ref,
- dest_pack,
- dest_action,
- overwrite=True,
- **kwargs,
- )
+ overwrite = True
else:
print("Action is not cloned.")
return
- else:
+
return self.manager.clone(
source_ref,
dest_pack,
dest_action,
- overwrite=False,
+ overwrite=overwrite,
**kwargs,
)
