fix(generator): Filter third-party services by active products#17971
fix(generator): Filter third-party services by active products#17971JamesDuncanNz wants to merge 1 commit into
Conversation
ea638db to
2bc9266
Compare
|
Googlers: For automatic test runs see go/terraform-auto-test-runs. @melinath, a repository maintainer, has been assigned to review your changes. If you have not received review feedback within 2 business days, please leave a comment on this PR asking them to take a look. You can help make sure that review is quick by doing a self-review and by running impacted tests locally. |
melinath
left a comment
There was a problem hiding this comment.
This isn't exactly a bug in the provider generator... but it does seem like a reasonable change that fixes a class of potentially-confusing compilation errors. The downstream diff looks good.
@roaks3 do you think this would cause any problems with nightly?
|
I can't immediately tell, is this fixing an urgent issue? If not, I would honestly probably hold off. It seems like more of a nice-to-have (if I'm understanding) that is touching a lot of core files with an LLM, and could break private providers in ways that are not obvious. |
|
I'm not aware of an urgent issue this is fixing. +1 that it seems like a nice to have. Holding off seems reasonable. |
Description
This PR fixes a bug in the Magic Modules generator where handwritten files for Beta-only (or version-restricted) services were being leaked into the GA provider, causing compilation failures - example.
The Problem
When introducing a new Beta-only service (such as the upcoming
agentregistry) that includes handwritten files inthird_party/terraform/services/<service_name>/(e.g.,agent_registry_operation.go), the GitHub Actions "Provider Build and Unit Test" job fails during the GA provider compilation with:undefined: Product
The Cause
product.go(which defines theProductvariable) is not created in the GA provider.CopyCommonFilesandCompileCommonFilesmethods were blindly copying/compiling the entirethird_party/terraform/services/directory to the downstream provider.agent_registry_operation.go) being copied to the GA provider (google/services/agentregistry/).Productvariable (which doesn't exist in GA for this service), the GA provider failed to compile.The Solution
This PR modifies the generator to only copy and compile third-party service files for products that are actually active in the target version being generated:
CopyCommonFilesin theProviderinterface and all its implementations to accept the list of activeproducts []*api.Product.getCommonCopyFilesinterraform.goto remove the globalthird_party/terraform/servicescopy. Instead, it now iterates through the activeproductsand only copiesthird_party/terraform/services/<product_name>if it exists.getCommonCompileFilesinterraform.gosimilarly to only compile templates for active products.dirExistshelper interraform.goto safely check if a service directory exists in the template filesystem before attempting to copy/compile it (as some services do not have handwritten files).This ensures that the GA provider remains completely free of any Beta-only service code, preventing compilation leaks.
Test/Verification Results
Verified locally by running:
make provider VERSION=ga(GA Generation) -> Verified that thegoogle/services/agentregistrydirectory is no longer created in the GA provider, resolving the compilation leak.make provider VERSION=beta(Beta Generation) -> Verified that thegoogle-beta/services/agentregistrydirectory is correctly created and contains all generated and handwritten files.Release Note Template for Downstream PRs (will be copied)