-
Notifications
You must be signed in to change notification settings - Fork 43
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
Use OpenTofu planner with Plugin Framework providers #2188
Conversation
bd2157d
to
01e1cde
Compare
So looks like I was misled on this change https://github.com/pulumi/pulumi-terraform-bridge/pull/2060/files#diff-4f84cec74d4ce22a6ead8a99011c4a9d47bbed3b56a5e7382b12aeda28cf05e6R78 @VenelinMartinov - the branching is not present in OpenTOFU sources. So re-vendoring the code from OpenTOFU now leads to failing tests. That's not a good state to be in. |
8a39d89
to
15dbda0
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.
I'd feel more comfortable if the vendored code lived in a pkg/vendor
directory, just so it's clearer which code is vendored.
Can you add to the README.md
s why each package is vendored? In general, I'm not super comfortable dropping down to vendored code unless we absolutely need to. I'd like to make sure that if we do need to do so, we have the reasons clearly listed so we know what we need to do to go back to standard go modules.
|
🤦 Of course it does. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2188 +/- ##
==========================================
- Coverage 60.68% 56.66% -4.03%
==========================================
Files 356 361 +5
Lines 46451 49443 +2992
==========================================
- Hits 28189 28015 -174
- Misses 16704 19891 +3187
+ Partials 1558 1537 -21 ☔ View full report in Codecov by Sentry. |
@@ -2,6 +2,7 @@ | |||
"changes": "DIFF_SOME", | |||
"diffs": [ | |||
"attrNumberComputed", | |||
"attrNumberRequired", |
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 think this is a correct result, this used to be a bug. Likely a degenerate case because a required property cannot be not specified in the program.
) | ||
|
||
// Assist converting Plugin framework schemata to proto schemata for a resource. | ||
func convertResourceSchemaToProto(ctx context.Context, s *rschema.Schema) (*tfprotov6.Schema, error) { |
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 a slightly convoluted way to convert rschema.Schema to protos. Perhaps could be avoided by vendoring internal code from the Plugin framework.
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 indeed quite roundabout - could we add a comment with a TODO here?
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 think I don't intend revisiting though, I think alternatives are worse.
}, | ||
Optional: true, | ||
}, | ||
"list": rschema.ListNestedAttribute{ | ||
NestedObject: rschema.NestedAttributeObject{ | ||
Attributes: map[string]rschema.Attribute{ | ||
"bar": rschema.StringAttribute{}, | ||
"bar": rschema.StringAttribute{Optional: true}, |
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.
These cases started failing because the schema was not valid.
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.
Thanks for updating the dependencies here!
) | ||
|
||
// Assist converting Plugin framework schemata to proto schemata for a resource. | ||
func convertResourceSchemaToProto(ctx context.Context, s *rschema.Schema) (*tfprotov6.Schema, error) { |
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 indeed quite roundabout - could we add a comment with a TODO here?
// TODO[pulumi/pulumi-terraform-bridge#2247]: patching objchange.ProposedNew changed behavior | ||
// | ||
// Want: object(map[string]valueBuilder{"foo": prim(nil)}), | ||
Want: unk(), |
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.
These all look "more correct" here in the absence of a planmodifier. Good to see we don't have any regressions with the objchange patch in pf
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 well maybe, these tests are a bit too low level to call which one we want.
@@ -0,0 +1,3 @@ | |||
# opentofu | |||
|
|||
Code vendored from [opentofu](https://github.com/opentofu/opentofu). Do not edit, use `go generate` to update. |
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 we add a CI check for vendored code to avoid any accidents here? Run go generate, check repo is clean. Fine as a follow-up.
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.
Rebased and tidied up #2168 Fixes #2170 This change confirms that the bug discovered in pulumi/pulumi-meraki#97 is now fixed in the latest bridge via #2188 --------- Co-authored-by: Venelin <[email protected]>
OpenTofu planner code is now used with Plugin Framework providers to emulate Terraform CLI behavior for
objchange.ProposedNew
. Note that this code was already in use for SDKv2-based resources prior to the change. The vendored code replaces a custom implementation that is now removed.Fixes #2172
Observable changes: Plugin Framework based resources may now reorder outputs for Set collections.
This change is known to fix bugs such as #2192 - to be confirmed with a regression test in a follow-up PR.