hashicorp / terraform-plugin-codegen-spec

Terraform Provider Code Generation Specification and Go Bindings
Mozilla Public License 2.0
7 stars 4 forks source link

spec: Use array of string for custom default, plan modifier, and validator imports #30

Closed bflad closed 1 year ago

bflad commented 1 year ago

Closes #28

When dealing with custom schema functionality, such as defaults, plan modifiers, and validators, the schema definition of these may require multiple code imports to successfully compile. This change adjusts the import specification of these from a single string to an array of strings. This also includes additional validation in the specification on those imports, leaving the imports property still optional, but if defined, it must contain at least one item and each item must not be an empty string.

As an example, the following specification definition wasn't possible before, but now is:

          {
            "name": "list_attribute_default_custom",
            "list": {
              "computed_optional_required": "optional_computed",
              "default": {
                "custom": {
                  "imports": [
                    "github.com/hashicorp/terraform-plugin-framework/attr",
                    "github.com/hashicorp/terraform-plugin-framework/resource/schema/listdefault",
                    "github.com/hashicorp/terraform-plugin-framework/types"
                  ],
                  "schema_definition": "listdefault.StaticValue(types.ListValueMust(types.String, []attr.Value{types.StringValue(\"example\")}))"
                }
              },
              "element_type": {
                "string": {}
              }
            }
          },
github-actions[bot] commented 3 months ago

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.