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

Publish diagnostics for non-autoloaded variable files (tfvars) #715

Open
radeksimko opened this issue Nov 17, 2021 · 0 comments
Open

Publish diagnostics for non-autoloaded variable files (tfvars) #715

radeksimko opened this issue Nov 17, 2021 · 0 comments

Comments

@radeksimko
Copy link
Member

Background

In #621 (part of 0.22.0+) we introduced parsing of non-autoloaded *.tfvars files (in addition to the autoloaded ones). This worked with the assumption that we only publish diagnostics when any individual file is opened and clear them when it's closed. This would reflect that invalid *.tfvars which are not autoloaded do not affect regular Terraform operations by default.

However we decided to refactor how diagnostics are handled in #714 which generally decoupled diagnostic publishing away from RPC request handlers, which in turn took away the opportunity to easily and quickly distinguish whether a file is opened or not.

As part of that refactoring we decided to avoid publishing diagnostics for these files as that basically aligns with how gopls handles diagnostics in similar cases - Go build tags.

Use-cases

Users should be able to see diagnostics as they edit any variable file (*.tfvars), but these diagnostics should not be distracting them if the file is actually never used.

Attempted Solutions

Publish diagnostics upon file opening and clear them upon closing.

Proposal

We could introduce a config option ExtraVarFiles []string to existing options

type Options struct {
// ModulePaths describes a list of absolute paths to modules to load
ModulePaths []string `mapstructure:"rootModulePaths"`
ExcludeModulePaths []string `mapstructure:"excludeModulePaths"`
CommandPrefix string `mapstructure:"commandPrefix"`
IgnoreDirectoryNames []string `mapstructure:"ignoreDirectoryNames"`
// ExperimentalFeatures encapsulates experimental features users can opt into.
ExperimentalFeatures ExperimentalFeatures `mapstructure:"experimentalFeatures"`
TerraformExecPath string `mapstructure:"terraformExecPath"`
TerraformExecTimeout string `mapstructure:"terraformExecTimeout"`
TerraformLogFilePath string `mapstructure:"terraformLogFilePath"`
}

However this only solves some scenarios as it assumes this setting would be LS-wide for the whole process.

Ideally we should let the user segment this configuration by folder. It is possible that we could leverage workspace/configuration here, but it's unclear what requirements does that have on the client side and which clients actually implement it and how.

Notes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants