Skip to content
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

pkg/registry: use v1beta1.CustomResourceDefinition, as the apiextensions type is internal #86

Merged

Conversation

estroz
Copy link
Member

@estroz estroz commented Sep 11, 2019

The type apiextensions.CustomResourceDefinition is an internal type that should not be used for unmarshaling. Instead v1beta1.CustomResourceDefinition should be used. When unmarshaling the former type, fields are not properly populated, ex. objectmeta.name is missing. Using a runtime.Decoder with Scheme will not cause JSON number issues (at least with one manual test).

/cc @ecordell @njhale

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 11, 2019
return err
crd := &v1beta1.CustomResourceDefinition{}
dec := serializer.NewCodecFactory(Scheme).UniversalDeserializer()
_, _, err = dec.Decode(cb, nil, crd)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will throw an error if a CRD version created in the future wasn't registered with Scheme. This is could be considered a feature ("we don't explicitly support that CRD version yet, throw an error"); simply using json.Unmarshal may cause silent marshaling errors like the one I describe in the PR comments. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That was the reasoning behind using the internal types in the first place, but it's reasonable to only support certain types.

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
the apiextensions type is internal
Copy link
Member

@ecordell ecordell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 12, 2019
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: ecordell, estroz

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 12, 2019
@openshift-merge-robot openshift-merge-robot merged commit 628ebd4 into operator-framework:master Oct 12, 2019
@estroz estroz deleted the fix-crd-encoding branch October 30, 2019 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants