Skip to content

Commit

Permalink
fix: fix delete/overwrite bug with workspaces
Browse files Browse the repository at this point in the history
Re #115
  • Loading branch information
ejseqera committed Mar 4, 2024
1 parent f4378e0 commit 09f04bf
Showing 1 changed file with 10 additions and 15 deletions.
25 changes: 10 additions & 15 deletions seqerakit/overwrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def __init__(self, sp):
"workspaces": {
"keys": ["name", "organization"],
"method_args": self._get_workspace_args,
"name_key": "workspaceId",
"name_key": "workspaceName",
},
}

Expand Down Expand Up @@ -101,7 +101,6 @@ def handle_overwrite(self, block, args, overwrite=False, destroy=False):
self.block_operations["participants"]["name_key"] = "teamName"
else:
self.block_operations["participants"]["name_key"] = "email"

if self.check_resource_exists(operation["name_key"], sp_args):
# if resource exists and overwrite is true, delete
if overwrite:
Expand Down Expand Up @@ -169,11 +168,7 @@ def _get_workspace_args(self, args):
workspaceId used to delete will be retrieved using the _find_workspace_id()
method.
"""
workspace_id = self._find_workspace_id(
json.loads(self.sp.workspaces.list("-o", "json")),
args["organization"],
args["name"],
)
workspace_id = self._find_workspace_id(args["organization"], args["name"])
return ("delete", "--id", str(workspace_id))

def _get_generic_deletion_args(self, args):
Expand Down Expand Up @@ -267,12 +262,12 @@ def _find_workspace_id(self, organization, workspace_name):
organization name and workspace name. This ID will be used to delete the
workspace.
"""
if "workspaces" in self.cached_jsondata:
workspaces = self.cached_jsondata["workspaces"]
for workspace in workspaces:
if (
workspace.get("orgName") == organization
and workspace.get("workspaceName") == workspace_name
):
return workspace.get("workspaceId")
jsondata = json.loads(self.cached_jsondata)
workspaces = jsondata["workspaces"]
for workspace in workspaces:
if (
workspace.get("orgName") == organization
and workspace.get("workspaceName") == workspace_name
):
return workspace.get("workspaceId")
return None

0 comments on commit 09f04bf

Please sign in to comment.