-
Notifications
You must be signed in to change notification settings - Fork 97
Add resource identity to Move RPC #1123
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
718b775
to
f3504cb
Compare
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.
Overall everything is looking good! I had a couple questions/nits
ee99491
to
335b4c0
Compare
// Try to set TargetIdentity even though req.IdentitySchema is nil | ||
resp.Diagnostics.Append(resp.TargetIdentity.SetAttribute(ctx, path.Root("test_id"), "should-not-be-set")...) |
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 is the scenario we're trying to prevent, if a provider does this it'll send back identity data to Terraform despite it not "announcing" an identity schema for the resource 🙂:
// Try to set TargetIdentity even though req.IdentitySchema is nil | |
resp.Diagnostics.Append(resp.TargetIdentity.SetAttribute(ctx, path.Root("test_id"), "should-not-be-set")...) | |
// This resource doesn't indicate identity support (via a schema), so this should raise a diagnostic. | |
resp.TargetIdentity = &tfsdk.ResourceIdentity{ | |
Raw: tftypes.NewValue(testIdentitySchema.Type().TerraformType(ctx), map[string]tftypes.Value{ | |
"test_id": tftypes.NewValue(tftypes.String, "should-not-be-set"), | |
}), | |
Schema: testIdentitySchema, | |
} |
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 doesn't raise a diagnostic now, should 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.
Yeah it should be raising a diagnostic, it looks like the check being on line 228 was too early because resp.TargetIdentity
is not set at that point (it's at moveStateResp.TargetIdentity
when it comes back from your provider code that sets it).
Other RPCs just immediately set resp.Identity
after the RPC, but if you want to move that piece of logic down lower we can also do that!
I'll make a comment suggestion 👍🏻
c974c77
to
5746ebf
Compare
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.
🎉
… MoveState Request
… still failing tests
Co-authored-by: Austin Valle <[email protected]>
Co-authored-by: Austin Valle <[email protected]>
Co-authored-by: Austin Valle <[email protected]>
Co-authored-by: Austin Valle <[email protected]>
Co-authored-by: Austin Valle <[email protected]>
092543b
to
097c894
Compare
Follow-Up PR for #1112
This PR implements MoveResourceState (Move) for identity.