Completion of required_providers source
and version
from Terraform Registry
#871
Labels
enhancement
New feature or request
providers
Functionality related to Terraform providers
textDocument/completion
Background
Terraform has a rich ecosystem of providers published in the Terraform Registry.
In order to use a provider in Terraform 0.12+, the user has to declare it explicitly, e.g.
We provide completion for most of the above, except for the values of
source
andversion
. As a result, unless the user is copy-pasting the provider address and/or version they can make a mistake which would be preventable with completion.Expected User Experience
source
Upon typing
>= 2
characters, the user will be provided with a list of providers from the Registry matching the typed name. e.g. if they typead
then the following list of 14 providers would come up:https://registry.terraform.io/search/providers?q=ad
version
Upon completion, the user will be provided with a list of published versions of a given provider, e.g. in case of
hashicorp/aws
they will see the following:3.46.0
3.45.0
3.44.0
Proposal
hashicorp/hcl-lang
#868
hashicorp/terraform-schema
CompletionHooks
formodule
source
toCompleteRegistryProviderSources
&CompleteLocalProviderSources
earlydecoder
to obtain and track each requirement's*hcl.Range
withinmodule.Meta
so that the completion hook forversion
has enough contextCompletionHooks
formodule
version
toCompleteRegistryProviderVersions
hashicorp/terraform-ls
module.Meta
as above in stateterraform-ls/internal/state/module.go
Lines 18 to 26 in 687a81b
Meta
ofPathContext
to allowCompleteRegistryProviderVersions
to establish which module source it should provide versions forCompleteRegistryProviderSources
completion hook to return addresses of modules from the Registry/AlgoliaCompleteLocalProviderSources
completion hook to return paths of all indexed modules (relative to where they're being called from)CompleteRegistryProviderVersions
completion hook to return versions of a given Registry module from the RegistryCompleteRegistryProviderSources
,CompleteLocalProviderSources
andCompleteRegistryProviderVersions
to theDecoderContext
terraform-ls/internal/decoder/decoder.go
Lines 82 to 85 in f49cd99
ResolveRegistryProviderSource
resolve hook for module source descriptionResolveRegistryProviderVersion
resolve hook for module version descriptionImplementation Notes
tf-registry:prod:providers
, relevant App ID & API key is in team 1Password although realistically we'll end up just baking it into the source code and none of it is secret per sehttps://registry.terraform.io/v2/providers/{PROVIDER_ID}/provider-versions
, e.g. https://registry.terraform.io/v2/providers/323/provider-versionsThe text was updated successfully, but these errors were encountered: