-
Notifications
You must be signed in to change notification settings - Fork 26
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
required_providers: warn on legacy version syntax, missing source #64
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this.
Agreed that we should warn against the legacy syntax and omitted sources, but I wonder if these should be enforced as a default for all users. Perhaps many users only use official providers such as AWS or Google, and explicitly declaring the source can simply feel redundant.
Nonetheless, since the behavior of omitting the source is clearly explained as a backward compatibility feature, the user should originally declare the source. The issue is that when updating TFLint, all users will have to manually fix every required_providers
declaration by hand.
I believe that providing an auto-fix is the desired behavior when forcing such a fix for low-impact legacy syntax, as Terraform provided the 0.12upgrade
subcommand. See terraform-linters/tflint#266
Another option might be to provide it as another rule or control the behavior with an option of this rule.
What do you think?
I'd hesitate to split out too many individual rules, enforcing Auto-fixing would be nice if we had the framework to offer it. Arguably it should make a network call to check that the given provider exists in the hashicorp namespace before writing anything out. The cost of omitting |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Agreed with this change.
I'll add config options for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Tightens enforcement of
required_providers
:source
source
is defined with the object syntaxThis is a breaking change, since previously these legacy syntaxes were accepted. It seems appropriate to focus on enforcement for modern TF versions and stop accommodating old/unsupported TF versions. While omitting a version constraint can lead to major issues down the road, omitting
source
is also a common hazard, albeit more of an immediate one.https://developer.hashicorp.com/terraform/language/providers/requirements#source-addresses
Closes #62