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

configs: Error on invalid required_providers attrs #26184

Merged
merged 1 commit into from
Sep 11, 2020

Conversation

alisdair
Copy link
Contributor

@alisdair alisdair commented Sep 9, 2020

A few users have recently been confused about the purpose of the required_providers objects, adding provider configuration parameters in addition to version and source. This previously did not cause an error so would result in a confusingly distant failure.

This commit adds a single diagnostic for any required_providers object which includes attributes other than version or source. Very open to suggestions on the diagnostic text!

Fixes #26160

Screenshot

required-providers-attrs

A few users have recently been confused about the purpose of the
required_providers objects, adding provider configuration parameters in
addition to version and source. This previously did not cause an error
so would result in a confusingly distant failure.

This commit adds a single diagnostic for any required_providers object
which includes attributes other than version or source.
@alisdair alisdair requested a review from a team September 9, 2020 15:53
@alisdair alisdair self-assigned this Sep 9, 2020
@codecov
Copy link

codecov bot commented Sep 9, 2020

Codecov Report

Merging #26184 into master will increase coverage by 0.10%.
The diff coverage is 75.97%.

Impacted Files Coverage Δ
backend/local/backend_local.go 41.23% <ø> (ø)
internal/getproviders/types.go 37.90% <0.00%> (-0.94%) ⬇️
terraform/eval_provider.go 83.33% <50.00%> (-4.17%) ⬇️
internal/depsfile/locks.go 67.74% <67.74%> (ø)
internal/depsfile/locks_file.go 75.39% <75.39%> (ø)
terraform/node_data_refresh.go 87.14% <78.94%> (-7.69%) ⬇️
terraform/node_output.go 68.24% <79.66%> (+2.22%) ⬆️
configs/provider_requirements.go 81.05% <100.00%> (+2.48%) ⬆️
terraform/node_data_destroy.go 100.00% <100.00%> (ø)
terraform/node_resource_refresh.go 89.07% <100.00%> (+0.12%) ⬆️
... and 5 more

Copy link
Contributor

@pselle pselle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: would we refer to this as an "object" or is "block" more appropriate?

@alisdair
Copy link
Contributor Author

alisdair commented Sep 9, 2020

Good question! I looked into what language we use elsewhere, and I think object is the right choice here.

required_providers is a block, but each of its attributes' values is either a string or an object. Another diagnostic uses this language in user-facing text:

diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Invalid required_providers syntax",
Detail: "required_providers entries must be strings or objects.",
Subject: attr.Expr.Range().Ptr(),
})

The documentation also refers to the value as an object:

Each argument in the required_providers block enables one provider. The key determines the provider's local name (its unique identifier within this module), and the value is an object with the following elements:

Copy link
Contributor

@mildwonkey mildwonkey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for grabbing this so quickly! ❤️ 🎉

@ghost
Copy link

ghost commented Oct 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

terraform should warn when unexpected attributes are in required_providers
3 participants