fix(import): aggregate CRD imports from same API group#3798
Open
mateo-moon wants to merge 1 commit intocdk8s-team:2.xfrom
Open
fix(import): aggregate CRD imports from same API group#3798mateo-moon wants to merge 1 commit intocdk8s-team:2.xfrom
mateo-moon wants to merge 1 commit intocdk8s-team:2.xfrom
Conversation
When importing multiple CRD files from the same Kubernetes API group (e.g., `compute.gcp.upbound.io`) using separate entries in `cdk8s.yaml`, all CRDs should be consolidated into a single module. Previously, each import was processed independently, causing later imports to overwrite earlier ones from the same API group. This change aggregates all unprefixed CRD imports, downloads all their manifests, combines them with YAML document separators, and processes them together. This ensures CRDs from the same API group are properly consolidated regardless of whether they come from the same file or different files/URLs. CRD imports with a `moduleNamePrefix` continue to be processed individually to preserve the user's intent for separate modules. Fixes cdk8s-team#3797 Signed-off-by: OP <op@cicd.ninja>
auto-merge was automatically disabled
February 3, 2026 01:19
Head branch was pushed to by a user without write access
c80f2b5 to
a43bb74
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes an issue where importing multiple CRD files from the same Kubernetes API group would cause earlier imports to be overwritten by later ones.
The Problem
When importing multiple CRD files from the same API group (e.g.,
compute.gcp.upbound.io) using separate entries:Only
Subnetwork(from the second import) would be available in the generated module. TheNetworkclass from the first import was overwritten.The Solution
---)ImportCustomResourceDefinitionmoduleNamePrefixare still processed individually (preserves user intent)Changes
src/import/dispatch.ts: AddedcategorizeImports()function to group imports by type, then process unprefixed CRDs togethersrc/import/crd.ts: AddedfromSpecs()andfromManifest()static methodstest/import/import-crd.test.ts: Added 3 test cases for the aggregation behaviortest/import/fixtures/: Added test fixture files for same-group CRD testingUse Case
This is especially important when importing Crossplane provider CRDs, where each managed resource type is in its own CRD file but shares the same API group.
Fixes #3797
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license