Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is an example of upgrading tflint-plugin-sdk for a ruleset plugin. v0.10.0 is a major update and all ruleset plugins will be affected. This PR has an aspect as a migration guide from v0.9.0.
All rules must embed
tflint.DefaultRule
A new
tflint.DefaultRule
has been introduced. All rules must embed this structure to satisfy the interface.This feature acts as the default for each rule and is intended to mitigate incompatibilities in future updates.
Severity()
must returntflint.Severity
For historical reasons, the
Severity()
method returned a string instead of an enum. However, it could return an arbitrary string, so it was replaced by an enum.WalkResourceAttributes
is obsolete and replaced byGetResourceContent
For more flexible access to attributes, the
WalkResourceAttributes
API has been deprecated and a schema-basedGetResourceContent
has been introduced.before
after
The advantage of this way is that it can handle multiple attributes at the same time. It makes easier to implement processing such as emitting an issue only for resources with an invalid combination of
instance_type
andami
.See also the tflint-plugin-sdk documentation for how to specify the schema with the hclext package.
WalkResourceBlocks
is obsolete and replaced byGetResourceContent
Similarly, the
WalkResourceBlocks
API has been obsoleted.before
after
Note that
hcl.Body
cannot be handled in rules. The schema inside the nested block must be specified at once.WalkResources
is obsolete and replaced byGetResourceContent
Similar to the above,
WalkResources
has also been obsoleted. As far as I know, the purpose of this API is to inspect multiple attribute combinations and should be able to be replaced by theWalkResourceAttributes
example.WalkModuleCalls
,Backend
, andConfig
are obsolete and replace byGetModuleContent
Similar to
GetResourceContent
, schema-based acquisition is possible for structures other than resources.EmitIssueOnExpr()
is obsolete, useEmitIssue()
For the module inspection, it was necessary to use different APIs to distinguish between issues for expressions and issues for ranges. However, this limitation has been lifted in the new API and
EmitIssue()
is now available for expression issues as well.There are some other changes, but see terraform-linters/tflint-plugin-sdk#135 for more information. If you have any questions about the migration, you can open an issue in the tflint-plugin-sdk repository.