-
Notifications
You must be signed in to change notification settings - Fork 182
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
Provide diagnostics and quick fixes for invalid configuration #720
Comments
self.*
references in provisioner
, connection
and lifecycle
blocks
hashicorp/terraform-ls#859
I ran into this today. Inline Also the invalidation of the errors is a bit hit and miss.
I could also argue, why not let users decide what is suitable for them and what is not. |
Can you be a bit more specific about what part of it is horrible? It's not clear to me whether you're talking about
Can you expand on this a bit more and explain how it is relevant to the original issue outlined above? I'd like to also point out that the intentions outlined in this issue are not to fully re-implement or further deepen integration with the |
Problem Statement
User today already receives diagnostics for invalid HCL syntax, such as missing curly braces, double quotes etc.
User can also trigger the
terraform validate
command which displays any validation warnings and errors in the form of diagnostics.terraform validate
is usually an expensive operation providing rich validation as defined by provider developers, therefore unsuitable to run as the user types.User would benefit from a lighter and "cheaper" validation based on provider schema that strikes the balance between the two.
User would also benefit from being able to "quick fix" violations semi-automatically via contextual code actions.
Expected User Experience
Users will be presented with diagnostics the same way that
validate
or HCL diagnostics are presented:but these diagnostics will be based on the violation of the (static) schema, for example
var.example
for no correspondingvariable "example"
blocknumber_field = "string"
variable "one" "two" {
variable {}
and based on knowledge of mistakes users have made in the past which Terraform CLI already returns, for example
required_providers
in root instead of enclosed withinterraform
blockrequred_providers
)All such diagnostics will be presented immediately as the user types.
Proposal
Must haves:
ValidateFilePerSchema()
hcl-lang#57validateBody
hcl-lang#287validateBody
should supportAnyAttribute
hcl-lang#289validateBody
should support schema extensions hcl-lang#290validateBody
should ignore missing provider schemas hcl-lang#291didChange
terraform-ls#1339Nice to haves:
Validate missing required module inputsdonetfvars
files terraform-ls#1410Prototype
terraform-ls: https://github.com/hashicorp/terraform-ls/compare/poc-earlyvalidation
ignore the command and code action related changes
hcl-lang: https://github.com/hashicorp/hcl-lang/compare/poc-earlyvalidation
Notes / Postponed ideas
hcl-lang
ValidateFilePerSchema()
hcl-lang#57required_providers
block underterraform
block (and/or creating it around)hcl-lang
in some generic wayThe text was updated successfully, but these errors were encountered: