-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
types/basetypes: Add Tuple type support #870
Conversation
For some reason I forgot that the documentation existed in this repo 😖, updated the PR with the tuple docs ⚡ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me 🚀 Just a few minor suggestions.
I wasn't 100% sure if we needed to implement (TupleType).ApplyTerraform5AttributePathStep for dynamic attributes, so I can update the implementation to return an error if that's not needed.
Adding the correct implementation now (which it looks like you did), rather than potentially discovering that as an issue later, is definitely appreciated!
@@ -83,7 +83,7 @@ Call one of the following to create a `types.List` value: | |||
* [`types.ListUnknown(attr.Type) types.List`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListUnknown): An unknown list value with the given element type. | |||
* [`types.ListValue(attr.Type, []attr.Value) (types.List, diag.Diagnostics)`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListValue): A known value with the given element type and values. | |||
* [`types.ListValueFrom(context.Context, attr.Type, any) (types.List, diag.Diagnostics)`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListValueFrom): A known value with the given element type and values. This can convert the source data from standard Go types into framework types as noted in the documentation for each element type, such as giving `[]*string` for a `types.List` of `types.String`. | |||
* [`types.ListValueMust(map[string]attr.Type, map[string]attr.Value) types.List`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListValueMust): A known value with the given element type and values. Any diagnostics are converted to a runtime panic. This is recommended only for testing or exhaustively tested logic. | |||
* [`types.ListValueMust(attr.Type, []attr.Value) types.List`](https://pkg.go.dev/github.com/hashicorp/terraform-plugin-framework/types#ListValueMust): A known value with the given element type and values. Any diagnostics are converted to a runtime panic. This is recommended only for testing or exhaustively tested logic. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I definitely did NOT find this because I was copy pasting the docs 😅
Co-authored-by: Brian Flad <bflad417@gmail.com>
Co-authored-by: Brian Flad <bflad417@gmail.com>
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. |
Ref: #54
This PR introduces
basetypes.TupleType
,basetypes.TupleValue
, and tuple helper functions/aliases in thetypes
package. This PR does not introduce any accompanyingTupleAttribute
implementations, so currently there is no way to describe this schema to Terraform core.Eventually when #147 is implemented, the
TupleType
will be necessary to fully handle dynamic attributes, as then Terraform core could possible send a tuple to Plugin Framework.Notes
types.Tuple
is not supported. Also added tests around the code that was refactored relating to sets/listsInto
andFromValue
, so I created table tests for them and added tests for just what I refactored. We can continually update the tests as we make changes tointernal/reflect
(TupleType).ApplyTerraform5AttributePathStep
for dynamic attributes, so I can update the implementation to return an error if that's not needed.