Skip to content

Commit

Permalink
Merge pull request #44 from pablerass/add-lock-commands
Browse files Browse the repository at this point in the history
Add lock commands
  • Loading branch information
brikis98 authored Oct 28, 2016
2 parents ae89c3c + fb68ce1 commit 5e4189c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions cli/cli_app.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ USAGE:
COMMANDS:
apply Acquire a lock and run 'terraform apply'
destroy Acquire a lock and run 'terraform destroy'
import Acquire a lock and run 'terraform import'
remote push Acquire a lock and run 'terraform remote push'
release-lock Release a lock that is left over from some previous command
* Terragrunt forwards all other commands directly to Terraform
{{if .VisibleFlags}}
Expand Down Expand Up @@ -146,7 +148,7 @@ func configureRemoteState(cliContext *cli.Context, remoteState *remote.RemoteSta
// We only configure remote state for the commands that use the tfstate files. We do not configure it for
// commands such as "get" or "version".
switch cliContext.Args().First() {
case "apply", "destroy", "graph", "output", "plan", "push", "refresh", "show", "taint", "untaint", "validate":
case "apply", "destroy", "import", "graph", "output", "plan", "push", "refresh", "show", "taint", "untaint", "validate":
return remoteState.ConfigureRemoteState()
case "remote":
if cliContext.Args().Get(1) == "config" {
Expand All @@ -166,8 +168,14 @@ func configureRemoteState(cliContext *cli.Context, remoteState *remote.RemoteSta
// Run the given Terraform command with the given lock (if the command requires locking)
func runTerraformCommandWithLock(cliContext *cli.Context, lock locks.Lock) error {
switch cliContext.Args().First() {
case "apply", "destroy":
case "apply", "destroy", "import":
return locks.WithLock(lock, func() error { return runTerraformCommand(cliContext) })
case "remote":
if cliContext.Args().Get(1) == "push" {
return locks.WithLock(lock, func() error { return runTerraformCommand(cliContext) })
} else {
return runTerraformCommand(cliContext)
}
case "release-lock":
return runReleaseLockCommand(cliContext, lock)
default:
Expand Down

0 comments on commit 5e4189c

Please sign in to comment.