terraform-plugin-framework icon indicating copy to clipboard operation
terraform-plugin-framework copied to clipboard

function: Add validation to prevent collection parameters/return definitions from having missing element types

Open austinvalle opened this issue 11 months ago • 0 comments

Module version

v1.6.0

Use-cases

#931 will introduce a new internal interface fwfunction.ParameterWithValidateImplementation and fwfunction.ReturnWithValidateImplementation that will enable us to implement logic for validating function parameter and return definitions.

We should introduce validation on all collection parameter and return definitions to ensure that element types are populated.

resp.Definition = function.Definition{
    Parameters: []function.Parameter{
        function.ListParameter{
            Name: "list",
            // Missing element type!
        },
    },
    Return: function.ListReturn{
        // Missing element type!
    },
}

Proposal

Implementation could look similar to collection attributes, such as ListAttribute: https://github.com/hashicorp/terraform-plugin-framework/blob/f86c88c9700c4bd03743b32382b20694577d71a7/datasource/schema/list_attribute.go#L210-L212

We should add this to:

  • ListParameter
  • ListReturn
  • MapParameter
  • MapReturn
  • SetParameter
  • SetReturn

References

  • #931

austinvalle avatar Mar 20 '24 14:03 austinvalle