Skip to content
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: Introduce ListValueFrom, MapValueFrom, ObjectValueFrom, and SetValueFrom functions #522

Merged
merged 2 commits into from Oct 25, 2022

Conversation

bflad
Copy link
Member

@bflad bflad commented Oct 24, 2022

Closes #520

These will enable provider developers to use the framework type system's built-in conversion rules to create collection types, rather than using more generic tfsdk.ValueFrom() or other methodologies.

In this example, a map using standard Go types is used to create a types.Map framework type with known values:

apiMap := map[string]string{
  "key1": "value1",
  "key2": "value2",
}
fwMap, diags := types.MapValueFrom(ctx, types.StringType, apiMap)

There may be additional use cases or needs that get teased out with this introduction, such as the ability to create a types.Object from a map[string]any, however those can be handled in potential future feature requests.

…tValueFrom functions

Reference: #520

These will enable provider developers to use the framework type system's built-in conversion rules to create collection types, rather than using more generic `tfsdk.ValueFrom()` or other methodologies.

In this example, a map using standard Go types is used to create a `types.Map` framework type with known values:

```go
apiMap := map[string]string{
  "key1": "value1",
  "key2": "value2",
}
fwMap, diags := types.MapValueFrom(ctx, types.StringType, apiMap)
```

There may be additional use cases or needs that get teased out with this introduction, such as the ability to create a `types.Object` from a `map[string]any`, however those can be handled in potential future feature requests.
@bflad bflad added the enhancement New feature or request label Oct 24, 2022
@bflad bflad added this to the v0.15.0 milestone Oct 24, 2022
@bflad bflad requested a review from a team as a code owner October 24, 2022 19:48
Copy link
Contributor

@bendbennett bendbennett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@bflad bflad merged commit de565fa into main Oct 25, 2022
@bflad bflad deleted the bflad/types-valuefrom branch October 25, 2022 13:09
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

types: Consider Adding Collection Type ValueFrom Functions
2 participants