Browse Source

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

Lock on all commands
pull/54/merge
Jacob McCann 7 years ago
committed by GitHub
parent
commit
63fe8f4c0f
  1. 4
      DOCS.md
  2. 18
      plugin.go

4
DOCS.md

@ -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.

18
plugin.go

@ -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",

Loading…
Cancel
Save