feat(terraform): check if worksapces supported

This commit is contained in:
Denis Gukov 2024-12-02 03:03:55 +05:00
parent c91b428de4
commit b8529b5c24

View File

@ -95,6 +95,16 @@ func (t *TerraformApp) init(environmentVars *[]string) error {
return cmd.Wait()
}
func (t *TerraformApp) isWorkspacesSupported(environmentVars *[]string) bool {
cmd := t.makeCmd(string(t.Name), []string{"workspace", "list"}, environmentVars)
err := cmd.Run()
if err != nil {
return false
}
return true
}
func (t *TerraformApp) selectWorkspace(workspace string, environmentVars *[]string) error {
cmd := t.makeCmd(string(t.Name), []string{"workspace", "select", "-or-create=true", workspace}, environmentVars)
t.Logger.LogCmd(cmd)
@ -112,6 +122,10 @@ func (t *TerraformApp) InstallRequirements(environmentVars *[]string) (err error
return
}
if !t.isWorkspacesSupported(environmentVars) {
return
}
workspace := "default"
if t.Inventory.Inventory != "" {