0
0
mirror of https://github.com/thegeeklab/wp-opentofu.git synced 2024-06-03 04:49:42 +02:00

Merge pull request #55 from jrynyt/lock-on-all-commands

Lock on all commands
This commit is contained in:
Jacob McCann 2017-10-20 10:58:55 -05:00 committed by GitHub
commit 63fe8f4c0f
2 changed files with 20 additions and 2 deletions

View File

@ -196,10 +196,10 @@ specified multiple times. Flags specified later in the line override those
specified earlier if they conflict.
init_options.lock
: Lock the state file when locking is supported.
: Lock the state file when locking is supported. Default `true`.
init_options.lock-timeout
: Duration to retry a state lock.
: Duration to wait for a state lock. Default `0s`.
vars
: a map of variables to pass to the Terraform `plan` and `apply` commands.

View File

@ -210,6 +210,12 @@ func planCommand(config Config) *exec.Cmd {
if config.Parallelism > 0 {
args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism))
}
if config.InitOptions.Lock != nil {
args = append(args, fmt.Sprintf("-lock=%t", *config.InitOptions.Lock))
}
if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
return exec.Command(
"terraform",
args...,
@ -234,6 +240,12 @@ func applyCommand(config Config) *exec.Cmd {
if config.Parallelism > 0 {
args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism))
}
if config.InitOptions.Lock != nil {
args = append(args, fmt.Sprintf("-lock=%t", *config.InitOptions.Lock))
}
if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
args = append(args, "plan.tfout")
return exec.Command(
"terraform",
@ -251,6 +263,12 @@ func destroyCommand(config Config) *exec.Cmd {
if config.Parallelism > 0 {
args = append(args, fmt.Sprintf("-parallelism=%d", config.Parallelism))
}
if config.InitOptions.Lock != nil {
args = append(args, fmt.Sprintf("-lock=%t", *config.InitOptions.Lock))
}
if config.InitOptions.LockTimeout != "" {
args = append(args, fmt.Sprintf("-lock-timeout=%s", config.InitOptions.LockTimeout))
}
args = append(args, "-force")
return exec.Command(
"terraform",