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

controller-gen Unknown supported Kind Interface when generating crd #294

Closed
szediktam opened this issue Aug 2, 2019 · 7 comments
Closed

Comments

@szediktam
Copy link

szediktam commented Aug 2, 2019

I use kubebuilder to building api by using crds.
when I generate crd by controller-gen, with a command:
controller-gen crd
it occurs an error:
Unknown supported Kind Interface

The reason is, in my crd types, I use a interface to accept any object.
I want to generate a "object" item in crd. An example as following:
type RequestBody interface {
}
CRD define:

    body:
        description: Request body
        type: object

But the controller-gen donot support interface kind to generate crd.
A bug? Or any other way to make it.
Thanks.

@DirectXMan12
Copy link
Contributor

For the moment, at least, I'd use json.RawMessage here as the underlying type. That should work fine. We decided to not support this because it's not recommended as part of the Kubernetes API conventions, but we can revisit that decision if it proves onerous.

@DirectXMan12
Copy link
Contributor

alternatively, runtime.RawExtension will covert the equivalent for specifically Kubernetes-related raw JSON blobs.

@szediktam
Copy link
Author

Thanks for your reply. @DirectXMan12
But how to use json.RawMessage or runtime.RawExtension to make it.
Can you show me an example?

@szediktam
Copy link
Author

I use runtime.RawExtension as the type, and generated a object type in crd.
RawExtension.Raw is []byte, unmarshal it to interface to process the data.

@szediktam
Copy link
Author

Using interface type is a direct idea for user to generate crd.
Maybe it is onerous to support interface type. @DirectXMan12

@DirectXMan12
Copy link
Contributor

sorry, I'm having trouble parsing your issue with RawExtension -- it's designed for when you need to represent an arbitrary Kubernetes object.

Using interface type is a direct idea for user to generate crd.

Sorry, I'm having trouble parsing what you're trying to say here.

@szediktam
Copy link
Author

sorry for my poor english.
I use runtime.RawExtension to solve my problem.

But, I think it is necessary to support initerface type when generate crds by controller-gen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants