0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-11-22 10:40:39 +00:00

Delete .terraform cache

Terraform will pull and cache config.  This causes issues if you
try to change remotes as the cache will be pushed to your remote
when it initializes the new remote.
This commit is contained in:
Jacob McCann 2016-02-18 18:09:23 -06:00
parent 42eef7a9aa
commit 409c5359c5

10
main.go
View File

@ -38,12 +38,14 @@ func main() {
commands = append(commands, installCaCert(vargs.Cacert)) commands = append(commands, installCaCert(vargs.Cacert))
} }
if remote.Backend != "" { if remote.Backend != "" {
commands = append(commands, deleteCache())
commands = append(commands, remoteConfigCommand(remote)) commands = append(commands, remoteConfigCommand(remote))
} }
commands = append(commands, planCommand(vargs.Vars)) commands = append(commands, planCommand(vargs.Vars))
if !vargs.Plan { if !vargs.Plan {
commands = append(commands, applyCommand()) commands = append(commands, applyCommand())
} }
commands = append(commands, deleteCache())
for _, c := range commands { for _, c := range commands {
c.Env = os.Environ() c.Env = os.Environ()
@ -72,6 +74,14 @@ func installCaCert(cacert string) *exec.Cmd {
) )
} }
func deleteCache() *exec.Cmd {
return exec.Command(
"rm",
"-rf",
".terraform",
)
}
func remoteConfigCommand(config remote) *exec.Cmd { func remoteConfigCommand(config remote) *exec.Cmd {
args := []string{ args := []string{
"remote", "remote",