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
Refine path model and path assumptions #661
Conversation
@@ -135,12 +131,16 @@ func (nt *schemaNestedTypes) declareType(path *paths.TypePath, | |||
requiredOutputs = required | |||
} | |||
|
|||
// Merging makes sure that structurally identical types are shared and not generated more than once. |
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 interesting bit in the tfgen algorithm! Adding a comment to highlight it.
Diff for pulumi-azuread with merge commit 21b31d5 |
Diff for pulumi-random with merge commit 21b31d5 |
Diff for pulumi-gcp with merge commit 21b31d5 |
Diff for pulumi-azure with merge commit 21b31d5 |
Diff for pulumi-aws with merge commit 21b31d5 |
Diff for pulumi-azure with merge commit 9364284 |
Diff for pulumi-aws with merge commit 9364284 |
Diff for pulumi-random with merge commit 17d4956 |
Diff for pulumi-azuread with merge commit 17d4956 |
Diff for pulumi-gcp with merge commit 17d4956 |
Diff for pulumi-azure with merge commit 17d4956 |
Diff for pulumi-aws with merge commit 17d4956 |
f8f81a5
to
17ccd48
Compare
Diff for pulumi-azuread with merge commit 2dfe1eb |
Diff for pulumi-random with merge commit 2dfe1eb |
Diff for pulumi-gcp with merge commit 2dfe1eb |
Diff for pulumi-azure with merge commit 2dfe1eb |
Diff for pulumi-aws with merge commit 2dfe1eb |
The paths module is used internally to track where we are in the schema during conversion. This refactors it a bit to simplify the model and introduces an interesting correction that helps clarify the tfgen process.
When allocating a named object type, tfgen actually merges structurally identical entries into a single new named object type. Therefore, several distinct paths in the schema may correspond to a new object type token. This is now explicit via PathSet.
It is interesting whether it is possible for the merging to happen across modules, and which module to place the generated type into if that's the case. I believe it's not possible, but now there is a panic/assert checking for that case.