-
Notifications
You must be signed in to change notification settings - Fork 236
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
all: Add support for write-only attributes #1375
Conversation
… `PlanResourceChange()`
…plement validation in `ValidateResourceTypeConfig()` RPC
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.
All of this is looking awesome, great work! I left some initial comments, but in addition to that:
- I'm wondering what will eventually show up in the plan renderer for Terraform... since we are planning non-null values that will eventually be set to null. Feels like it should either explicitly mention that the value is write-only, or we should be planning
null
for write-only attributes as well. We should make a note to come back to this once core gets further along. - It'd be cool to get some corner testing for SDKv2 to catch any regressions we might introduce in the future
- I'd love to run this development branch against a major cloud TF provider (aws/gcp/azure) if we can get a hand from their teams finding the appropriate CI jobs to do so. They have so many SDKv2 schemas + tests that it would be a good smoke test.
- We would need them to update their plugin-go/mux/etc, so you might need to adjust the plugin-go branch to make that all compile.
Co-authored-by: Austin Valle <[email protected]>
…teRawResourceConfigFuncs`
# Conflicts: # go.mod # go.sum # helper/schema/grpc_provider.go
// | ||
// GetRawConfigAt is considered advanced functionality, and | ||
// familiarity with the Terraform protocol is suggested when using it. | ||
func (d *ResourceData) GetRawConfigAt(valPath cty.Path) (cty.Value, diag.Diagnostics) { |
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 would check that this works for nested blocks; specifically traversing across cty.SetVal
values is weird and I think cty.Walk
is going to fail there.
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.
Good callout! I've added more test cases in commit d1d4c14. The Set and Set nested block traversal test cases are passing 👍🏾
var oldAttrs []attribute | ||
|
||
err := cty.Walk(req.RawConfig, func(path cty.Path, value cty.Value) (bool, error) { | ||
if PathMatches(path, oldAttribute) { |
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.
should all cty.Walk' calls use
PathMatches`? Or are they expected to only have paths from what should be matching objects?
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'm using PathMatches
as a quick and dirty equivalent to the framework's path expressions to indicate locations in the schema (as opposed to schema-based data like config).
The cty.Walk
in GetRawConfigAt()
could also use PathMatches
although it's not entirely clear what exactly the resulting cty.Value
should be when specifying "any" nested block in the path, so I'm leaning on waiting for a feature request asking for such functionality. The only downside is that cty.Path
now works differently in the SDKv2 depending on the function it's being used for which could be confusing.
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.
Looks good! I left some comments, mostly just considerations for documentation. (will re-approve if there are more changes pushed to the PR)
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 see there are a bunch of suggestions here, so I kept my review light. Happy to go through this again after you get a chance to review Austin's comments! ✨
Co-authored-by: Austin Valle <[email protected]>
Co-authored-by: Austin Valle <[email protected]>
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.
All good from Web Presence POV
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.
Great work! 🚀
Adds support for new write-only attribute feature in Terraform
v1.11
or higher. Write-only attributes are managed resource attributes whose values are not saved to the Terraform plan or state artifacts and can accept ephemeral values.A provider can declare an attribute as write-only in the schema using the
WriteOnly
field. Write-only attributes values are only available in the configuration, and the prior state, planned state, and final state values for write-only attributes should always benull
.