Skip to content

Commit 5e4189c

Browse files
authored
Merge pull request #44 from pablerass/add-lock-commands
Add lock commands
2 parents ae89c3c + fb68ce1 commit 5e4189c

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

cli/cli_app.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ USAGE:
2626
COMMANDS:
2727
apply Acquire a lock and run 'terraform apply'
2828
destroy Acquire a lock and run 'terraform destroy'
29+
import Acquire a lock and run 'terraform import'
30+
remote push Acquire a lock and run 'terraform remote push'
2931
release-lock Release a lock that is left over from some previous command
3032
* Terragrunt forwards all other commands directly to Terraform
3133
{{if .VisibleFlags}}
@@ -146,7 +148,7 @@ func configureRemoteState(cliContext *cli.Context, remoteState *remote.RemoteSta
146148
// We only configure remote state for the commands that use the tfstate files. We do not configure it for
147149
// commands such as "get" or "version".
148150
switch cliContext.Args().First() {
149-
case "apply", "destroy", "graph", "output", "plan", "push", "refresh", "show", "taint", "untaint", "validate":
151+
case "apply", "destroy", "import", "graph", "output", "plan", "push", "refresh", "show", "taint", "untaint", "validate":
150152
return remoteState.ConfigureRemoteState()
151153
case "remote":
152154
if cliContext.Args().Get(1) == "config" {
@@ -166,8 +168,14 @@ func configureRemoteState(cliContext *cli.Context, remoteState *remote.RemoteSta
166168
// Run the given Terraform command with the given lock (if the command requires locking)
167169
func runTerraformCommandWithLock(cliContext *cli.Context, lock locks.Lock) error {
168170
switch cliContext.Args().First() {
169-
case "apply", "destroy":
171+
case "apply", "destroy", "import":
170172
return locks.WithLock(lock, func() error { return runTerraformCommand(cliContext) })
173+
case "remote":
174+
if cliContext.Args().Get(1) == "push" {
175+
return locks.WithLock(lock, func() error { return runTerraformCommand(cliContext) })
176+
} else {
177+
return runTerraformCommand(cliContext)
178+
}
171179
case "release-lock":
172180
return runReleaseLockCommand(cliContext, lock)
173181
default:

0 commit comments

Comments
 (0)