Skip to content
Snippets Groups Projects
Commit c6a4f229 authored by Juraj Paluba's avatar Juraj Paluba
Browse files

Merge branch 'update-deletion-of-stack' into 'master'

add method to switch workspace

See merge request !9
parents a9b03e9f 6cc875c4
No related branches found
No related tags found
1 merge request!9add method to switch workspace
Pipeline #147160 passed
......@@ -83,6 +83,18 @@ class KypoTerraformClientManager:
stdout=terraform_state_file, stderr=subprocess.PIPE)
self.wait_for_process(process)
def _switch_terraform_workspace(self, workspace: str, stack_dir: str) -> None:
"""
Switch Terraform workspace.
:param workspace: The name of the workspace.
:param stack_dir: The path to the stack directory
:return: None
"""
process = subprocess.Popen(['terraform', 'workspace', 'select', workspace], cwd=stack_dir,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
self.wait_for_process(process)
@staticmethod
def create_directories(dir_path: str) -> None:
"""
......@@ -239,7 +251,7 @@ class KypoTerraformClientManager:
except TerraformInitFailed:
return None
except TerraformWorkspaceFailed:
pass
self._switch_terraform_workspace(stack_name, stack_dir)
return subprocess.Popen(['terraform', 'destroy', '-auto-approve', '-no-color'],
cwd=stack_dir, stdout=subprocess.PIPE, text=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment