-
Notifications
You must be signed in to change notification settings - Fork 382
Open
Labels
enhancementneeds-designDetailed design is required for implementationDetailed design is required for implementation
Description
Introduction
The .tflint.hcl configuration schema has remained largely unchanged since its design, but I believe there are better designs out there now. The current (v0.50) schema is shown below:
config {
call_module_type = string
force = bool
ignore_module = map(bool)
varfile = list(string)
variables = list(string)
disabled_by_default = bool
plugin_dir = string
format = string
}
plugin "name" {
enabled = bool
version = string
source = string
signing_key = string
[plugin custom fields]
}
rule "name" {
enabled = bool
[plugin custom fields]
}This schema has the following issues:
- Top-level
configblock is redundant. As I recall, this was introduced simply for implementation reasons at the time. This limitation no longer exists. ignore_moduleis set by a module source, not an ID, so you cannot ignore a module exactly. Also, originally,list(string)should be enough instead ofmap(bool).varfileis poorly named. Given that the CLI flag in Terraform is--var-file,var_fileis appropriate.var_filesis the best because it accepts multiple files.variablesis accepted as simple string, but HCL allows for more flexible expressions. Imagine being able to write*.tfvarsinline.- There is a mix of different types of attributes within the
configblock. For example, it may be easier to understand if attributes that affect inspection and attributes that affect output are grouped in separate blocks. - Plugin custom fields and reserved fields may conflict. Adding new reserved attributes in the future may impact existing plugins.
- Since rules are provided by plugins, it might be possible to nest
ruleblocks insidepluginblocks.
Proposal
Redesign config schema like below:
force = bool
disabled_by_default = bool
plugin_dir = string
format = string
terraform {
var_files = list(map)
variables = {
foo = "bar"
baz = 1
}
ignore_modules = list(string)
call_module_type = string
}
plugin "name" {
enabled = bool
version = string
source = string
signing_key = string
_ {
[plugin custom fields]
}
rule "name" {
enabled = bool
_ {
[plugin custom fields]
}
}
}However, this is a draft and we do not guarantee that it will be changed to this schema. The final version should be considered for backward compatibility and impact on changes.
References
- https://github.com/terraform-linters/tflint/blob/v0.50.0/docs/user-guide/config.md
- https://developer.hashicorp.com/terraform/cli/config/config-file
- https://terragrunt.gruntwork.io/docs/reference/config-blocks-and-attributes/
- https://developer.hashicorp.com/terraform/language/values/variables
- Mechanisms to allow for future language extension hashicorp/terraform#28709
Skaronator and changyoung-hyperithm
Metadata
Metadata
Assignees
Labels
enhancementneeds-designDetailed design is required for implementationDetailed design is required for implementation