Skip to content

Commit 755f211

Browse files
authored
helper/resource: Add Terraform configuration to TRACE logging (#1059)
Reference: #700 For example: ```console $ TF_ACC=1 TF_LOG=TRACE go test -count=1 -run='TestTest_TestStep_ExternalProviders_DifferentVersions' -v ./helper/resource ... 2022-09-13T22:40:05.009-0400 [TRACE] sdk.helper_resource: Setting Terraform configuration: test_name=TestTest_TestStep_ExternalProviders_DifferentVersions test_step_number=1 test_terraform_path=/opt/homebrew/bin/terraform test_working_directory=/var/folders/f3/2mhr8hkx72z9dllv0ry81zm40000gq/T/plugintest971555752 test_terraform_config= | | terraform { | required_providers { | null = { | source = "registry.terraform.io/hashicorp/null" | version = "3.1.0" | } | } | } | | provider "null" {} | ... ```
1 parent 0f41bb0 commit 755f211

File tree

3 files changed

+8
-0
lines changed

3 files changed

+8
-0
lines changed

.changelog/1059.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:enhancement
2+
helper/resource: Added Terraform configuration to `TRACE` logging
3+
```

internal/logging/keys.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ const (
3131
// The TestStep number of the test being executed. Starts at 1.
3232
KeyTestStepNumber = "test_step_number"
3333

34+
// Terraform configuration used during acceptance testing Terraform operations.
35+
KeyTestTerraformConfiguration = "test_terraform_configuration"
36+
3437
// The Terraform CLI logging level (TF_LOG) used for an acceptance test.
3538
KeyTestTerraformLogLevel = "test_terraform_log_level"
3639

internal/plugintest/working_dir.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ func (wd *WorkingDir) GetHelper() *Helper {
7676
// Destroy to establish the configuration. Any previously-set configuration is
7777
// discarded and any saved plan is cleared.
7878
func (wd *WorkingDir) SetConfig(ctx context.Context, cfg string) error {
79+
logging.HelperResourceTrace(ctx, "Setting Terraform configuration", map[string]any{logging.KeyTestTerraformConfiguration: cfg})
80+
7981
outFilename := filepath.Join(wd.baseDir, ConfigFileName)
8082
rmFilename := filepath.Join(wd.baseDir, ConfigFileNameJSON)
8183
bCfg := []byte(cfg)

0 commit comments

Comments
 (0)