-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Create a registry package for products to self-register resources #16244
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: main
Are you sure you want to change the base?
Conversation
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 5967 Click here to see the affected service packages
Action takenFound 2 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🟢 All tests passed! |
melinath
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.
Overall makes sense / looks good. A few questions & change requests below.
| } | ||
|
|
||
| type registeredProducts struct { | ||
| sync.RWMutex |
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 should be a pointer to avoid copying the mutex per https://pkg.go.dev/sync#Mutex: "A Mutex must not be copied after first use."
| sync.RWMutex | |
| *sync.RWMutex |
I'm not sure whether we can achieve that like this... possibly this needs to be a real field on the struct & Lock/Unlock callers need to access the mutex directly.
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 changed the instantiations to be pointers. They're package-private types and their instantiations are package-private, which also prevents copying.
| } | ||
|
|
||
| // Schema is used to configure a resource or data source within the registry. | ||
| type Schema struct { |
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.
Why does this use a single Schema struct w/ SchemaType instead of having different structs per registerable type? It feels like resource/datasource are handled sufficiently differently that it could be easier to use if they were kept separate. (I don't feel very strongly about this, just curious about the reasoning.)
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 thought about it but ultimately decided that since this is just a small wrapper around the Terraform schema type, and that type handles both data sources and resources that this wrapper would too.
| _ = schema.Noop | ||
| ) | ||
|
|
||
| func init() { |
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 is ending up in TGC, but the other registration blocks aren't. This seems a little surprising. Might cause problems?
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.
In theory it's harmless, but I've modified the template to avoid it on TGC.
…gnore_schema_changes(dataPolicies) is defined (#15006)
…ility policy block. (#15916)
…6013) Co-authored-by: Mike Prieto <[email protected]> Co-authored-by: Shuya Ma <[email protected]> Co-authored-by: jgforsberg <[email protected]> Co-authored-by: shang-jason <[email protected]> Co-authored-by: Zhenhua Li <[email protected]> Co-authored-by: Taneli Leppä <[email protected]> Co-authored-by: Hank Freund <[email protected]> Co-authored-by: Ning Kang <[email protected]> Co-authored-by: Ning Kang <[email protected]> Co-authored-by: nshah-google <[email protected]> Co-authored-by: Riley Karson <[email protected]> Co-authored-by: diegomguzman-google <[email protected]> Co-authored-by: Nandini Agrawal <[email protected]> Co-authored-by: Max Portocarrero CI&T <[email protected]> Co-authored-by: Ricardo Godoy <[email protected]> Co-authored-by: sushilchaskar28 <[email protected]> Co-authored-by: Chi-Pin <[email protected]> Co-authored-by: Björn <[email protected]> Co-authored-by: Rahul Jaideoka <[email protected]> Co-authored-by: shivangd <[email protected]> Co-authored-by: shubhechha-google <[email protected]> Co-authored-by: Andras Kerekes <[email protected]> Co-authored-by: Luca Prete <[email protected]> Co-authored-by: Stephane Charite <[email protected]> Co-authored-by: Thomas Rodgers <[email protected]> Co-authored-by: sreemoyee-basu <[email protected]> Co-authored-by: Nicolas Dumazet <[email protected]>
Co-authored-by: rlapin-pl <[email protected]>
Co-authored-by: Shuya Ma <[email protected]>
Co-authored-by: Ramon Vermeulen <[email protected]>
Co-authored-by: Riley Karson <[email protected]>
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
|
Hi there, I'm the Modular magician. I've detected the following information about your changes: Diff reportYour PR generated some diffs in downstreams - here they are.
|
Tests analyticsTotal tests: 5977 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🔴 Tests failed when rerunning REPLAYING mode: Tests failed due to non-determinism or randomness when the VCR replayed the response after the HTTP request was made. Please fix these to complete your PR. If you believe these test failures to be incorrect or unrelated to your change, or if you have any questions, please raise the concern with your reviewer. 🟢 All tests passed! |
Tests analyticsTotal tests: 5980 Click here to see the affected service packages
Action takenFound 1 affected test(s) by replaying old test recordings. Starting RECORDING based on the most recent commit. Click here to see the affected tests
|
|
🟢 Tests passed during RECORDING mode: 🟢 No issues found for passed tests after REPLAYING rerun. 🟢 All tests passed! |
This is part of the Bazel work, which includes much more modularized builds. Right now the MM compiler can only generate a provider or integration tests that include every product, resource, and data source. The main reason for that is how these are cataloged in the provider: they are imported at compile time and statically registered. In the future, they will be discovered at runtime and dynamically registered.
This PR also switches MMv1 resource discovery to use the registry. It's still static compile-time registration, but with a step toward the aforementioned dynamic registration. Handwritten and DCL resources will come in subsequent PRs, and then the switch to fully dynamic.
The registry ended up in its own package due to circular dependencies. In the future it can probably be moved into the
providerpackage, but not for now as static registration means that the provider package depends on product packages, and product packages will always depend on the provider package.Probably the most important thing to check is the diff in the generated versions of
google[-beta]/provider/provider_mmv1_resources.go. The assignments ingeneratedIAMDatasourcesandgeneratedResourcesshould match 1:1, with the right hand side now coming from the registry.