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: Prevent Inconsistent dependency lock file errors when using ExternalProviders outside the hashicorp namespace #1057

Merged
merged 2 commits into from Sep 14, 2022

Commits on Sep 14, 2022

  1. helper/resource: Prevent Inconsistent dependency lock file errors w…

    …hen using `ExternalProviders` outside the `hashicorp` namespace
    
    By default, Terraform CLI will use the `registry.terraform.io` hostname and `hashicorp` namespace for provider addresses if there is not a `terraform` configuration block with an explicit configuration. Previously, the testing framework would automatically generate a temporary configuration with the `terraform` configuration block for running `terraform init`, but it did not include this extra configuration along with a given `TestStep` `Config`. When working with `hashicorp` namespace providers, this isn't an issue because of the Terraform CLI defaults.
    
    External provider developers could manually workaround this issue by including the `terraform` configuration block as part of their `TestStep` `Config`, however this is certainly confusing and error prone.
    
    Previously before code adjustments:
    
    ```
    === CONT  TestTest_TestCase_ExternalProviders_NonHashiCorpNamespace
        testcase_providers_test.go:236: Step 1/1 error: Error running pre-apply refresh:
            Error: Inconsistent dependency lock file
    
            The following dependency selections recorded in the lock file are
            inconsistent with the current configuration:
              - provider registry.terraform.io/hashicorp/scaffoldingtest: required by this configuration but no version is selected
    
            To update the locked dependency selections to match a changed configuration,
            run:
              terraform init -upgrade
    --- FAIL: TestTest_TestCase_ExternalProviders_NonHashiCorpNamespace (1.91s)
    
    === CONT  TestTest_TestCase_ExternalProvidersAndProviderFactories_NonHashiCorpNamespace
        testcase_providers_test.go:258: Step 1/1 error: Error running pre-apply refresh:
            Error: Inconsistent dependency lock file
    
            The following dependency selections recorded in the lock file are
            inconsistent with the current configuration:
              - provider registry.terraform.io/hashicorp/scaffoldingtest: required by this configuration but no version is selected
    
            To update the locked dependency selections to match a changed configuration,
            run:
              terraform init -upgrade
    --- FAIL: TestTest_TestCase_ExternalProvidersAndProviderFactories_NonHashiCorpNamespace (0.46s)
    
    === CONT  TestTest_TestStep_ExternalProviders_NonHashiCorpNamespace
        teststep_providers_test.go:304: Step 1/1 error: Error running pre-apply refresh:
            Error: Inconsistent dependency lock file
    
            The following dependency selections recorded in the lock file are
            inconsistent with the current configuration:
              - provider registry.terraform.io/hashicorp/scaffoldingtest: required by this configuration but no version is selected
    
            To update the locked dependency selections to match a changed configuration,
            run:
              terraform init -upgrade
    --- FAIL: TestTest_TestStep_ExternalProviders_NonHashiCorpNamespace (0.32s)
    
    === CONT  TestTest_TestStep_ExternalProvidersAndProviderFactories_NonHashiCorpNamespace
        teststep_providers_test.go:325: Step 1/1 error: Error running pre-apply refresh:
            Error: Inconsistent dependency lock file
    
            The following dependency selections recorded in the lock file are
            inconsistent with the current configuration:
              - provider registry.terraform.io/hashicorp/scaffoldingtest: required by this configuration but no version is selected
    
            To update the locked dependency selections to match a changed configuration,
            run:
              terraform init -upgrade
    --- FAIL: TestTest_TestStep_ExternalProvidersAndProviderFactories_NonHashiCorpNamespace (0.35s)
    ```
    bflad committed Sep 14, 2022
    Copy the full SHA
    5511b66 View commit details
    Browse the repository at this point in the history
  2. Update CHANGELOG for #1057

    bflad committed Sep 14, 2022
    Copy the full SHA
    17541d0 View commit details
    Browse the repository at this point in the history