-
Notifications
You must be signed in to change notification settings - Fork 50
Simplify PF attr obj shim #2232
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
base: vvm/tfgen_name_override_bug_repro
Are you sure you want to change the base?
Simplify PF attr obj shim #2232
Conversation
|
The failing tests even expects this:
It says it asserts on type |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## vvm/tfgen_name_override_bug_repro #2232 +/- ##
======================================================================
- Coverage 67.48% 56.44% -11.05%
======================================================================
Files 325 305 -20
Lines 41633 40393 -1240
======================================================================
- Hits 28096 22798 -5298
- Misses 11957 15927 +3970
- Partials 1580 1668 +88 ☔ View full report in Codecov by Sentry. |
iwahbe
left a comment
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.
It looks like this change is correct. I'm extremely surprised there are not runtime implications to this.
|
I believe we must have been already handling both as both are present. I'll sit on this for a bit |
| assert.Equal(t, shim.TypeList, shimmed.Type()) | ||
| assert.NotNil(t, shimmed.Elem()) | ||
| _, isPseudoResource := shimmed.Elem().(shim.Schema) | ||
| _, isPseudoResource := shimmed.Elem().(shim.Resource) |
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.
Assert on next line interestingly said it expects Resource, but the cast is casting to shim.Schema.
|
This may be a better encoding, but this is pretty error-prone, I wonder if we could complement this with some tests taking this for a spin end to end. Specifically, for tfgen layer and runtime handling:
|
|
Also sounds like an update on the Elem() doc comment is needed here for this case. |
|
Yeah, some end-to-end tests are certainly needed - thanks for the suggestions on what to focus on! I'll also revisit the Elem docs. |
|
I expect there is a big encoding bug here somewhere. Map-nested attributes https://developer.hashicorp.com/terraform/plugin/framework/handling-data/attributes/map-nested But they might clobber each other in the shim.Schema representation with Type=TypeMap, Elem()=Resource. Also in SDKv2 TypeMap, Elem()=Resource means a degenerate case of |
This is invalid in SDKv2 - only lists and sets can have an Elem Resource |
|
IT is admitted though, and valid, per doc in Elem() and https://github.com/hashicorp/terraform-plugin-sdk/blob/main/helper/schema/core_schema_test.go#L220 |
|
Wondering if any providers actually use this - I doubt it works well |
|
We have to make it an error though, or else to make the schema Map<string,string>, since it's a possibility. |
|
Yeah, absolutely, great point about Map nested Resource elems in SDKv2 |
|
AS time permits, could we rebase on #2456 and have another peek at the interesting bits with the generated Pulumi Schema side-by-side? Could be a good learning experience. Thanks! |
|
This change is part of the following stack: Change managed by git-spice. |
5253750 to
9617124
Compare
ba46990 to
071d00c
Compare
6cf0650 to
ad04b40
Compare
ad04b40 to
8322504
Compare
We seem to represent list-nested objects in the shim layer differently depending on if it is an attr or block.
The attribute one seems overly complicated:
list: {element: schema: element: resource}vslist: element: resourcefor blocks.This is an attempt at simplifying it - not fully tested yet.