Skip to content

Commit 510e818

Browse files
committed
feat(tf): gen backend file
1 parent d3a0176 commit 510e818

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

db_lib/TerraformApp.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,27 @@ func (t *TerraformApp) selectWorkspace(workspace string, environmentVars []strin
196196

197197
func (t *TerraformApp) InstallRequirements(environmentVars []string, tplParams any, params any) (err error) {
198198

199+
tpl := tplParams.(*db.TerraformTemplateParams)
199200
p := params.(*db.TerraformTaskParams)
200201

201-
err = t.init(environmentVars, p)
202-
if err != nil {
202+
if tpl.OverrideBackend {
203+
err = os.WriteFile(path.Join(t.GetFullPath(), "backend.tf"), []byte("terraform { backend \"http\" {} }"), 0644)
204+
if err != nil {
205+
return
206+
}
207+
}
208+
209+
if err = t.init(environmentVars, p); err != nil {
203210
return
204211
}
205212

213+
if tpl.OverrideBackend {
214+
err = os.Remove(path.Join(t.GetFullPath(), "backend.tf"))
215+
if err != nil {
216+
return
217+
}
218+
}
219+
206220
workspace := "default"
207221

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

0 commit comments

Comments
 (0)