File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11.idea
22src /build /
3+ src /build * /
34config.tf
45environment.tf
56.env
6- bin
7+ bin
Original file line number Diff line number Diff line change 44 "bytes"
55 "gopkg.in/alecthomas/kingpin.v2"
66 "path/filepath"
7+ "strconv"
78 "strings"
89 "text/template"
910)
@@ -36,6 +37,7 @@ type BackendConfig struct {
3637 TerraformStateKey string
3738 TerraformLockTable string
3839 KmsKeyArn string
40+ TerraformVersion int
3941}
4042
4143type dotEnv struct {
@@ -161,6 +163,10 @@ func (c *BackendCommand) applyInvoker(config *BackendConfig) {
161163 c .log .ShowOpts ("Invoker" , "enabled" )
162164 config .TerraformStateKey = strings .Join ([]string {config .TerraformStateKey , defaultTerraformInvokerSuffix }, "-" )
163165 }
166+
167+ if config .TerraformVersion >= 2 {
168+ config .TerraformStateKey = config .TerraformStateKey + "/v" + strconv .Itoa (config .TerraformVersion )
169+ }
164170}
165171
166172func (c * BackendCommand ) dotEnvMapper (env * dotEnv ) * BackendConfig {
@@ -172,6 +178,7 @@ func (c *BackendCommand) dotEnvMapper(env *dotEnv) *BackendConfig {
172178 KmsKeyArn : env .environment ["KMS_KEY_ARN" ],
173179 TerraformStateKey : env .project ["TERRAFORM_STATE_KEY" ],
174180 Domain : env .project ["DOMAIN" ],
181+ TerraformVersion : c .app .IntResolver (env .project ["TERRAFORM_VERSION" ]),
175182 }
176183}
177184
Original file line number Diff line number Diff line change 11package main
22
3- const Version = "v0.5.0 "
3+ const Version = "v0.5.1 "
44
55const CiEnvVar = "CI"
66const EnvVersionVar = "TF_ENV_VERSION"
Original file line number Diff line number Diff line change 55 "github.com/joho/godotenv"
66 "os"
77 "path/filepath"
8+ "strconv"
89 "strings"
910 "text/template"
1011)
@@ -125,6 +126,14 @@ func (a *App) BoolResolver(text string) bool {
125126 return false
126127}
127128
129+ func (a * App ) IntResolver (text string ) int {
130+ if strings .EqualFold (text , "" ) || strings .EqualFold (text , "1" ) {
131+ return 1
132+ }
133+ intVar , _ := strconv .Atoi (text )
134+ return intVar
135+ }
136+
128137func (a * App ) isNewEnvVersion () bool {
129138 if strings .EqualFold (a .envVersion , "2" ) {
130139 return true
You can’t perform that action at this time.
0 commit comments