Fix empty TypeMeta while running API conversions #424
Merged
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 running the API conversion functions for multi-version CRDs, there are cases, as discussed in kubernetes/client-go#541, where the
v1.TypeMeta
information has been dropped. This breaks non-wildcard conversion function filtering performed by the conversion webhook.I have:
make reviewable
to ensure this PR is ready for review.Addedbackport release-x.y
labels to auto-backport this PR if necessary.How has this code been tested
Tested against
crossplane-contrib/provider-upjet-aws
resourceInstance.rds
with conversions between the versionsv1beta1
,v1beta2
, andv1beta3
. Here are the steps (Note that testing the fix requires building an image, because conversion functions won't work in a provider running outside of the cluster — unless you jump through the hoops):v1beta1
MR manifest below.kubectl get instance.v1beta2.rds.aws.upbound.io/test-upjet-pr-424-db
.name
field inv1beta1
was lost when converted to storage versionv1beta2
(field renaming conversion).kubectl get instance.v1beta2.rds.aws.upbound.io/test-upjet-pr-424-db
.name
field inv1beta1
was converted successfully todbName
inv1beta2
.Resource manifest
Note that we supply an invalid
providerConfigRef
to prevent provisioning the external resource, because we don't need the resource to test conversion functions.