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

Add support for provider-defined functions #320

Closed
3 tasks done
dbanck opened this issue Feb 6, 2024 · 0 comments · Fixed by #321
Closed
3 tasks done

Add support for provider-defined functions #320

dbanck opened this issue Feb 6, 2024 · 0 comments · Fixed by #321
Assignees
Labels
enhancement New feature or request

Comments

@dbanck
Copy link
Member

dbanck commented Feb 6, 2024

Background

We currently have a static list of all core functions in terraform-schema in the internal/funcs package. terraform-ls can consume this for a specific Terraform version via the FunctionsForVersion helper:

func FunctionsForVersion(v *version.Version) (map[string]schema.FunctionSignature, error) {
ver := v.Core()
if ver.GreaterThanOrEqual(v1_4) {
return funcs_generated.Functions(ver), nil
}

To support provider-defined functions, we need to merge the built-in functions with the dynamic functions from the provider schema.

Proposal

  • Add a Functions field to the provider schema to allow parsing from JSON
    type ProviderSchema struct {
    Provider *schema.BodySchema
    Resources map[string]*schema.BodySchema
    DataSources map[string]*schema.BodySchema
    }
  • Add functions signatures to the new field when parsing provider JSON
  • Introduce a new functions merger to combine the built-in functions with those defined by the provider. Similar to the existing SchemaMerger
    func NewSchemaMerger(coreSchema *schema.BodySchema) *SchemaMerger {
    return &SchemaMerger{
    coreSchema: coreSchema,
    }
    }
@dbanck dbanck transferred this issue from hashicorp/vscode-terraform Feb 6, 2024
@dbanck dbanck changed the title Add a Functions field to the provider schema to enable parsing from JSON Add support for provider-defined functions Feb 6, 2024
@dbanck dbanck added the enhancement New feature or request label Feb 6, 2024
@ansgarm ansgarm self-assigned this Feb 7, 2024
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

Successfully merging a pull request may close this issue.

2 participants