Skip to content

Consider modifying validation to account for duplicate names used in attributes and blocks #34

@bendbennett

Description

@bendbennett

Within the terraform-plugin-codegen-framework, models are generated from the specification. Currently, it is possible for the specification to contain names that are duplicated across attributes and blocks. For instance, the following intermediate representation is currently permitted

{
{
  "datasources": [
    {
      "name": "datasource",
      "schema": {
        "attributes": [
          {
            "name": "one",
          }
        ],
        "blocks": [
          {
            "name": "one",

This results in the generation of a valid schema with the following form:

datasourceDataSourceSchema = schema.Schema{
	Attributes: map[string]schema.Attribute{
		"one": /*...*/
	},
	Blocks: map[string]schema.Block{
		"one": /*...*/
	},
}

However, it also results in the generation of an invalid model with the following form:

type DatasourceModel struct {
	One types.Bool `tfsdk:"one"`
	One types.List `tfsdk:"one"`
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions