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

Improve completion for compound DependencyKeys #33

Open
radeksimko opened this issue Apr 14, 2021 · 0 comments
Open

Improve completion for compound DependencyKeys #33

radeksimko opened this issue Apr 14, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@radeksimko
Copy link
Member

See #32


In many cases DependencyKeys contains just labels

schema.DependencyKeys{
	Labels: []schema.LabelDependent{
		{Index: 0, Value: "azurerm_subnet"},
	},
}

but in some other cases the same dependent BodySchema is available under both simple and "compound" dependent key, such as

schema.DependencyKeys{
	Labels: []schema.LabelDependent{
		{Index: 0, Value: "azurerm_subnet"},
	},
	Attributes: []schema.AttributeDependent{
		{
			Name: "provider",
			Expr: schema.ExpressionValue{
				Address: lang.Address{
					lang.RootStep{Name: "azurerm"},
				},
			},
		},
	},
}

In such a case it is not entirely clear what candidates should we provide when completing labels for an empty block, as we can't just parse that empty body and restrict completion to label-only keys because the dependent attributes aren't declared. This would make it non-intuitive UX in Terraform where a provider may only be available under an alias, but we can't expect the user to by typing out that alias association inside the body before completing resource type.

For example:

terraform {
  required_providers {
    rand = {
      source  = "hashicorp/random"
      version = "3.0.0"
    }
  }
}

resource "<HERE>" "" {

}

^ User would likely expect to see all hashicorp/random resource types despite the fact that without provider = rand should be used.

The only reason the example above would still work when e.g. random_pet is completed is because Terraform then makes assumptions about the prefix (random_) and looks up the provider that way. Providers however aren't required to prefix resources with provider name, so this may not always work.

@radeksimko radeksimko added the enhancement New feature or request label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant