Skip to content

Commit

Permalink
Updated blocks.md design doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan De Marino committed May 25, 2022
1 parent 105798d commit d0b3fec
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions docs/design/blocks.md
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func (t exampleThingResourceType) GetSchema(_ context.Context) (Schema, diag.Dia
Required: true,
Type: types.StringType,
},
}, ListNestedAttributesOptions{}),
}),
},
},
}, nil
Expand Down Expand Up @@ -572,7 +572,7 @@ For example:
Type: types.StringType,
Required: true,
},
}, ListNestedBlocksOptions{}),
}),
},
```

Expand All @@ -591,15 +591,14 @@ For example:
Type: types.StringType,
Required: true,
},
}, ListNestedBlocksOptions{}),
}),
},
```

This allows the framework to differentiate between block and nested attributes by fields. This would allow for a potential block to attribute migration path of:

- Rename `Blocks` field identifier to `Attributes`
- Rename `ListNestedBlocks`/`SetNestedBlocks` call expressions to `ListNestedAttributes`/`SetNestedAttributes`
- Rename `ListNestedBlocksOptions`/`SetNestedBlocksOptions` declarations to `ListNestedAttributesOptions`/`SetNestedBlocksOptions`
- Either default to adding `Required`/`Optional`/`Computed` field identifier(s) and `true` value(s) or its a manual step for provider developers

However, this does introduce the possibility of creating a schema that passes compilation checks, but is not a valid schema. For example, `Attributes` that contains `Blocks` which is not possible in the protocol. At best the framework could introduce unit testable schema validation logic to catch this situation, or worse case, it would result in runtime errors for practitioners that get reported back to provider developers.
Expand Down

0 comments on commit d0b3fec

Please sign in to comment.