Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
helper/resource: Prevent
Inconsistent dependency lock file
errors w…
…hen using `ExternalProviders` outside the `hashicorp` namespace (#1057) 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) ```
- Loading branch information