Add config.Resource.PreviousVersions to specify the previous versions of an MR API #402
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.
Description of your changes
When generating new versions of the CRD APIs associated with a managed resource, upjet's code generation pipeline can potentially run into the following issue:
v1beta2
for resourceB
A
in the same group asB
, whose API is generated atv1beta1
v1beta1
version of theB
resource API is not generated and hence upjet is not aware of it. This results in name conflicts for the generated types.We have a roadmap item to modularize the code generation pipeline to make it more dynamic and scalable but it's a much larger effort. As a workaround, we had introduced the
config.Resource.OverrideFieldNames
API through which one can override the name upjet is generating for a CRD type. However, this requires manual configuration.For most cases, this has been feasible as we rarely do bulk breaking changes in the MR APIs. However recently, we are rolling out API changes across the official providers that replace the singleton lists in the MR APIs with embedded objects (please see #387 and crossplane-contrib/provider-upjet-gcp#508 for more context). Such systemic changes affecting multiple resources can result in a need to override the generated type names for many resources. What's worse, @sergenyalcin identified in crossplane-contrib/provider-upjet-azure#733 that the current
config.Resource.OverrideFieldNames
API is unable to handle certain types of overrides where we need to override the same leaf at multiple paths. We need to be able to specify the canonical paths of the overrides being defined.So, we've decided to address this issue by making upjet's code generation pipelines aware of the existing previous versions of the CRDs (MR APIs). One can configure an older version of an API as follows:
While generating the CRDs in a package, upjet will then load the type definitions from these previous versions specified and use them as input to its already existing name conflict resolution function.
We also deprecate the
config.Resource.OverrideFieldNames
API whose only known use case is preventing the type name conflicts in the generated CRDs. So,config.Resource.OverrideFieldNames
is deprecated in favor of the ``config.Resource.PreviousVersions`-based mechanism described above.I have:
make reviewable
to ensure this PR is ready for review.backport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Tested in the context of crossplane-contrib/provider-upjet-azure#733 & crossplane-contrib/provider-upjet-gcp#508. As an example, please observe the changes in here, where the API is replaced and we observe no diff in the generated APIs.