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

Merge source across required_providers blocks #46

Merged
merged 2 commits into from
May 26, 2020

Conversation

alisdair
Copy link
Contributor

Rebase of #44, to keep the required providers logic in sync with Terraform. See also: hashicorp/terraform#25034

If multiple terraform.required_providers blocks are in the config, we already merge the version constraints for each provider. We should also merge the source attribute, and warn if there are duplicates.

Consider the following configuration:

terraform {
  required_providers {
    foo = {
      version = "1.0.0"
    }
  }
}

terraform {
  required_providers {
    foo = {
      source = "abc/foo"
    }
  }
}

Before this commit, this would result in a provider requirement for "foo" with version "1.0.0", but no source. This commit merges the source attribute from the second block into this requirement.

alisdair added 2 commits May 26, 2020 14:46
If multiple terraform.required_providers blocks are in the config, we
already merge the version constraints for each provider. We should also
merge the source attribute, and warn if there are duplicates.

Consider the following configuration:

terraform {
  required_providers {
    foo = {
      version = "1.0.0"
    }
  }
}

terraform {
  required_providers {
    foo = {
      source = "abc/foo"
    }
  }
}

Before this commit, this would result in a provider requirement for
"foo" with version constraint "1.0.0", but no "source". This commit
merges the source attribute from the second block into this requirement.
Previously we were diagnosing multiple provider different provider
source attribute values as a warning, but this is really a configuration
error. This commit updates the diagnostic to be an error, and adds a
forced failure in the legacy parser when a `required_providers` block is
encountered to ensure that the error propagates.
@alisdair alisdair requested a review from a team as a code owner May 26, 2020 18:51
@mildwonkey mildwonkey requested a review from justincampbell May 26, 2020 19:20
@alisdair alisdair merged commit d43f12b into master May 26, 2020
@alisdair alisdair deleted the alisdair/provider-source-multiple-blocks branch May 26, 2020 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants