Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

helper/resource: Ensure Terraform CLI logs are written to TF_LOG_PATH_MASK environment variable value when both TF_ACC_LOG_PATH and TF_LOG_PATH_MASK are set #938

Merged
merged 3 commits into from Apr 14, 2022

Commits on Apr 12, 2022

  1. helper/resource: Ensure Terraform CLI logs are written to `TF_LOG_PAT…

    …H_MASK` environment variable value when both `TF_ACC_LOG_PATH` and `TF_LOG_PATH_MASK` are set
    
    Reference: #922
    
    The code refactoring centralizes all `(tfexec.Terraform).Set*` method calls right after `NewTerraform()` to ensure everything is immediately configured as expected.
    
    Verification via terraform-provider-corner after `go mod edit -replace`:
    
    ```console
    $ TF_ACC=1 TF_LOG=TRACE TF_ACC_LOG_PATH=/tmp/oops.txt TF_LOG_PATH_MASK=/tmp/better-%s.txt go test -count=1 -run='TestAccFrameworkResourceUser_interpolateLanguage' -v ./internal/frameworkprovider
    === RUN   TestAccFrameworkResourceUser_interpolateLanguage
    --- PASS: TestAccFrameworkResourceUser_interpolateLanguage (3.33s)
    PASS
    ok      github.com/hashicorp/terraform-provider-corner/internal/frameworkprovider       3.659s
    $ ls /tmp/*.txt
    /tmp/better-TestAccFrameworkResourceUser_interpolateLanguage.txt        /tmp/oops.txt
    $ cat /tmp/oops.txt
    $ head -20 /tmp/better-TestAccFrameworkResourceUser_interpolateLanguage.txt
    2022-04-12T14:28:37.074-0400 [DEBUG] sdk.helper_resource: Starting TestCase: test_name=TestAccFrameworkResourceUser_interpolateLanguage
    2022-04-12T14:28:37.074-0400 [TRACE] sdk.helper_resource: Adding potential Terraform CLI source of local filesystem PATH lookup: test_name=TestAccFrameworkResourceUser_interpolateLanguage
    2022-04-12T14:28:37.074-0400 [TRACE] sdk.helper_resource: Adding potential Terraform CLI source of checkpoint.hashicorp.com latest version for installation in: /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest-terraform902259129: test_name=TestAccFrameworkResourceUser_interpolateLanguage
    2022-04-12T14:28:37.075-0400 [DEBUG] sdk.helper_resource: Found Terraform CLI: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform
    2022-04-12T14:28:37.075-0400 [TRACE] sdk.helper_resource: Symlinking source directories to work directory: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273/work2021050956
    2022-04-12T14:28:37.111-0400 [TRACE] sdk.helper_resource: Setting terraform-exec log path via TF_ACC_LOG_PATH environment variable: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273/work2021050956 test_terraform_log_path=/tmp/oops.txt
    2022-04-12T14:28:37.111-0400 [TRACE] sdk.helper_resource: Setting terraform-exec log path via TF_LOG_PATH_MASK environment variable: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273/work2021050956 test_terraform_log_path=/tmp/better-TestAccFrameworkResourceUser_interpolateLanguage.txt
    2022-04-12T14:28:37.112-0400 [TRACE] sdk.helper_resource: Clearing Terraform plan: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273
    2022-04-12T14:28:37.112-0400 [TRACE] sdk.helper_resource: No Terraform plan to clear: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273
    2022-04-12T14:28:37.112-0400 [DEBUG] sdk.helper_resource: Creating tfprotov6 provider instance: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273 tf_provider_addr=registry.terraform.io/hashicorp/framework
    2022-04-12T14:28:37.112-0400 [DEBUG] sdk.helper_resource: Created tfprotov6 provider instance: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273 tf_provider_addr=registry.terraform.io/hashicorp/framework
    2022-04-12T14:28:37.112-0400 [DEBUG] sdk.helper_resource: Starting tfprotov6 provider instance server: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273 tf_provider_addr=registry.terraform.io/hashicorp/framework
    2022-04-12T14:28:37.113-0400 [DEBUG] sdk.helper_resource: Started tfprotov6 provider instance server: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273 tf_provider_addr=registry.terraform.io/hashicorp/framework
    2022-04-12T14:28:37.113-0400 [TRACE] sdk.helper_resource: Setting Terraform CLI reattach configuration: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273 tf_reattach_config="map[registry.terraform.io/-/framework:{grpc 6 62287 true {unix /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugin1464887819}} registry.terraform.io/hashicorp/framework:{grpc 6 62287 true {unix /var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugin1464887819}}]"
    2022-04-12T14:28:37.113-0400 [TRACE] sdk.helper_resource: Calling wrapped Terraform CLI command: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273
    2022-04-12T14:28:37.113-0400 [TRACE] sdk.helper_resource: Calling Terraform CLI init command: test_name=TestAccFrameworkResourceUser_interpolateLanguage test_terraform_path=/usr/local/bin/terraform test_working_directory=/var/folders/w8/05f3x02n27x72g0mc2jy6_180000gp/T/plugintest1623391273
    2022-04-12T14:28:37.144-0400 [INFO]  Terraform version: 1.1.8
    2022-04-12T14:28:37.144-0400 [INFO]  Go runtime version: go1.17.2
    2022-04-12T14:28:37.144-0400 [INFO]  CLI args: []string{"/usr/local/bin/terraform", "init", "-no-color", "-force-copy", "-input=false", "-backend=true", "-get=true", "-upgrade=false"}
    2022-04-12T14:28:37.144-0400 [TRACE] Stdout is not a terminal
    ...
    ```
    bflad committed Apr 12, 2022
    Copy the full SHA
    0c6beed View commit details
    Browse the repository at this point in the history
  2. Update CHANGELOG for #938

    bflad committed Apr 12, 2022
    Copy the full SHA
    e0d6d59 View commit details
    Browse the repository at this point in the history

Commits on Apr 14, 2022

  1. Copy the full SHA
    33b2995 View commit details
    Browse the repository at this point in the history