hashicorp / hashicorp/terraform-plugin-codegen-spec

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

Open
#34 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
12
Forks
9
Avg merge
2d 13h
Merged PRs (30d)
1

Description

Within the [terraform-plugin-codegen-framework](https://github.com/hashicorp/terraform-plugin-codegen-framework/pulls), models are generated from the [specification](https://github.com/hashicorp/terraform-plugin-codegen-spec/blob/main/spec/specification.go). 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

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

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

```go
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:

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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.