Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
K
kypo-terraform-client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MUNI-KYPO-CRP
backend-python
kypo-terraform-client
Commits
c6a4f229
Commit
c6a4f229
authored
3 years ago
by
Juraj Paluba
Browse files
Options
Downloads
Plain Diff
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
!9
add method to switch workspace
Pipeline
#147160
passed
3 years ago
Stage: build
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
kypo/terraform_driver/terraform_client_manager.py
+13
-1
13 additions, 1 deletion
kypo/terraform_driver/terraform_client_manager.py
with
13 additions
and
1 deletion
kypo/terraform_driver/terraform_client_manager.py
+
13
−
1
View file @
c6a4f229
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment