Skip to content

Commit b8529b5

Browse files
committed
feat(terraform): check if worksapces supported
1 parent c91b428 commit b8529b5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

db_lib/TerraformApp.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,16 @@ func (t *TerraformApp) init(environmentVars *[]string) error {
9595
return cmd.Wait()
9696
}
9797

98+
func (t *TerraformApp) isWorkspacesSupported(environmentVars *[]string) bool {
99+
cmd := t.makeCmd(string(t.Name), []string{"workspace", "list"}, environmentVars)
100+
err := cmd.Run()
101+
if err != nil {
102+
return false
103+
}
104+
105+
return true
106+
}
107+
98108
func (t *TerraformApp) selectWorkspace(workspace string, environmentVars *[]string) error {
99109
cmd := t.makeCmd(string(t.Name), []string{"workspace", "select", "-or-create=true", workspace}, environmentVars)
100110
t.Logger.LogCmd(cmd)
@@ -112,6 +122,10 @@ func (t *TerraformApp) InstallRequirements(environmentVars *[]string) (err error
112122
return
113123
}
114124

125+
if !t.isWorkspacesSupported(environmentVars) {
126+
return
127+
}
128+
115129
workspace := "default"
116130

117131
if t.Inventory.Inventory != "" {

0 commit comments

Comments
 (0)