-
Notifications
You must be signed in to change notification settings - Fork 97
New function ValueFrom
that takes a Go value and populates a compatible attr.Value
, given a descriptive attr.Type
#350
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
Conversation
Testing this locally now |
ValueFrom
that takes a Go value and populates a compatible attr.Value
, given a descriptive attr.Type
tfsdk/value_from_test.go
Outdated
Name types.String `tfsdk:"name"` | ||
Age types.Int64 `tfsdk:"age"` | ||
OptedIn types.Bool `tfsdk:"opted_in"` | ||
Address types.List `tfsdk:"address"` |
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.
Is it worth testing other types (e.g., types.Map
), along the lines of
Address types.Map `tfsdk:"address"`
Then using the following in personAttrTypes
:
"address": types.MapType{
ElemType: types.StringType,
},
Populating mrX
with:
Address: types.Map{
ElemType: types.StringType,
Elems: map[string]attr.Value{
"number": types.String{Value: "1"},
"street": types.String{Value: "Beckford Close"},
"town": types.String{Value: "Gotham"},
},
},
And finally testing expectedMrXObj
:
"address": types.Map{
ElemType: types.StringType,
Elems: map[string]attr.Value{
"number": types.String{Value: "1"},
"street": types.String{Value: "Beckford Close"},
"town": types.String{Value: "Gotham"},
},
},
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.
Just added it ;)
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.
Nice. Just a minor comment.
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. |
fixes #323