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: Add ObjectType with CustomType #26

Closed bflad closed 1 year ago

bflad commented 1 year ago

Closes #25

This breaking change ensures there is consistency that specification implementations can use CustomType with all types, in this case object types underlying any attribute type.

For existing implementations, such as:

{
            "name": "list_object_attribute",
            "list": {
              "computed_optional_required": "computed",
              "element_type": {
                "object": [
                  {
                    "name": "obj_string_attr",
                    "string": {}
                  }
                ]
              }
            }
          },

Are now defined as:

{
            "name": "list_object_attribute",
            "list": {
              "computed_optional_required": "computed",
              "element_type": {
                "object": {
                  "attribute_types": [
                    {
                      "name": "obj_string_attr",
                      "string": {}
                    }
                  ]
                }
              }
            }
          },

Note that there is now a slight inconsistency between how CustomType is defined on collection types (ListType, MapType, and SetType) that are already element types and need to include their own element type. The CustomType is specified along side the element type, rather than explicitly having an ElementType delineation.

Currently:

          {
            "name": "map_list_string_attribute",
            "map": {
              "computed_optional_required": "computed",
              "element_type": {
                "list": {
                  "custom_type": {
                    "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes",
                    "type": "basetypes.ListType",
                    "value_type": "basetypes.ListValue"
                  },
                  "string": {}
                }
              }
            }
          },

It may make sense to reintroduce what was originally designed in the specification with the verbose ElementType property for clarity.

          {
            "name": "map_list_string_attribute",
            "map": {
              "computed_optional_required": "computed",
              "element_type": {
                "list": {
                  "custom_type": {
                    "import": "github.com/hashicorp/terraform-plugin-framework/types/basetypes",
                    "type": "basetypes.ListType",
                    "value_type": "basetypes.ListValue"
                  },
                  "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.