Skip to content

Commit

Permalink
Make sure Terragrunt commands can be configured with -lock=true
Browse files Browse the repository at this point in the history
  • Loading branch information
dz-sourced committed Mar 19, 2021
1 parent a53c621 commit e638215
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
2 changes: 1 addition & 1 deletion modules/terraform/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TgApplyAllE(t testing.TestingT, options *Options) (string, error) {
return "", TgInvalidBinary(options.TerraformBinary)
}

return RunTerraformCommandE(t, options, FormatArgs(options, "apply-all", "-input=false", "-lock=false", "-auto-approve")...)
return RunTerraformCommandE(t, options, FormatArgs(options, "apply-all", "-input=false", "-auto-approve")...)
}

// ApplyAndIdempotent runs terraform apply with the given options and return stdout/stderr from the apply command. It then runs
Expand Down
18 changes: 18 additions & 0 deletions modules/terraform/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,21 @@ func TestParallelism(t *testing.T) {
duration := end.Sub(start)
require.Greater(t, int64(duration.Seconds()), int64(25))
}
func TestTgApplyUseLockNoError(t *testing.T) {
t.Parallel()

testFolder, err := files.CopyTerragruntFolderToTemp("../../test/fixtures/terragrunt/terragrunt-no-error", t.Name())
require.NoError(t, err)

options := WithDefaultRetryableErrors(t, &Options{
TerraformDir: testFolder,
TerraformBinary: "terragrunt",
Lock: true,
})

out := TgApplyAll(t, options)

require.Contains(t, out, "Hello, World")
// make sure -lock CLI option is passed down correctly
require.Contains(t, out, "-lock=true")
}
2 changes: 1 addition & 1 deletion modules/terraform/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func TgDestroyAllE(t testing.TestingT, options *Options) (string, error) {
return "", TgInvalidBinary(options.TerraformBinary)
}

return RunTerraformCommandE(t, options, FormatArgs(options, "destroy-all", "-force", "-input=false", "-lock=false")...)
return RunTerraformCommandE(t, options, FormatArgs(options, "destroy-all", "-force", "-input=false")...)
}
2 changes: 2 additions & 0 deletions modules/terraform/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ import (
var TerraformCommandsWithLockSupport = []string{
"plan",
"apply",
"apply-all",
"destroy",
"destroy-all",
"init",
"refresh",
"taint",
Expand Down

0 comments on commit e638215

Please sign in to comment.