You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Obtaining schema is expensive and can take ~1 second even on a smaller provider such as github.
We should consider caching the schema as part of initialize and invalidating the cache whenever the provider changes (as the schema it would output may changed).
We also might want to account for users storing providers outside of current work directory - i.e. we can just error out if there is no .terraform repository and no TF_PLUGIN_DIR ENV variable
The text was updated successfully, but these errors were encountered:
radeksimko
changed the title
Detect provider changes to cache schema
Watch provider changes to cache schema
Mar 6, 2020
The (currently simple) discovery *and* checking currently happens
during textDocument/completion, which is suboptimal from performance
and responsibility perspective, but it is an acceptable technical debt
as #16 will address that.
Closes#7
Possibly related to #15 - we might be able to watch for .terraform directory changes, but we need to reflect the reality of LSP clients not supporting workspace/didChangeWatchedFiles, such as Sublime Text
The reason we should consider implementing this method is because under certain conditions it would limit the number of file-watchers running alongside each other, potentially even monitoring the same files, which is suboptimal. The LSP's assumption is that there will usually be less clients than servers and so centralisation of such logic can save resources.
I decided not to implement it initially though, because we can't afford just having invalid cache when the client doesn't implement that method, so having a built-in watcher seems like a necessary baseline to start with.
We can however add this later to provide some resource relief to those who use clients that support this.
We also might want to account for users storing providers outside of current work directory - i.e. we can just error out if there is no .terraform repository and no TF_PLUGIN_CACHE_DIR ENV variable
There are actually two things I mixed up.
Firstly there is path for custom provider binaries - which seems to be always ~/.terraform.d/plugins / %APPDATA%\terraform.d\plugins with no way of overriding via any ENV variable.
The second one, which is the one LS should actually be interested in is the path to the plugin cache which can be set via CLI config file or ENV variable TF_PLUGIN_CACHE_DIR.
Importantly this does NOT mean we wouldn't support third party plugins - these can be installed into the appropriate location and will get picked up by terraform providers schema -json automatically and hashes will be stored in a lock file under the usual location (<workspace-dir>/.terraform/plugins/) after terraform init.
Obtaining schema is expensive and can take ~1 second even on a smaller provider such as
github
.We should consider caching the schema as part of
initialize
and invalidating the cache whenever the provider changes (as the schema it would output may changed).Possibly related to https://github.com/radeksimko/terraform-ls/issues/15 - we might be able to watch for
.terraform
directory changes, but we need to reflect the reality of LSP clients not supportingworkspace/didChangeWatchedFiles
, such as Sublime TextWe also might want to account for users storing providers outside of current work directory - i.e. we can just error out if there is no
.terraform
repository and noTF_PLUGIN_DIR
ENV variableThe text was updated successfully, but these errors were encountered: