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

CRD cannot be generated for Unstructured type #301

Closed
muvaf opened this issue Aug 7, 2019 · 3 comments · Fixed by #303
Closed

CRD cannot be generated for Unstructured type #301

muvaf opened this issue Aug 7, 2019 · 3 comments · Fixed by #303

Comments

@muvaf
Copy link
Contributor

muvaf commented Aug 7, 2019

We got a type that has *unstructured.Unstructured as one of its fields and we're generating CRD off of it. I am working on transition to controller-tools v0.2.0 and running into the following error:

github.com/crossplaneio/crossplane/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go:45:2: encountered struct field "Object" without JSON tag in type "Unstructured"

Looked into the source code and there really isn't a tag for Object field, however, even if I manually write the json tag, it returns the following:

github.com/crossplaneio/crossplane/vendor/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go:45:20: map values must be a named type, not *ast.InterfaceType

Is there a way to have controller-tools handle this? I imagine it's more complicated due to having interface{} as value but I'd appreciate if we can find a way for it to work. Note that it worked with version 0.1.9

You can see the ongoing work here crossplane/crossplane#665

You can see the versions used in Gopkg.toml.

To reproduce, checkout the PR and run make manifests

You can also try to have *unstructured.Unstructured typed field in any struct and try to generate CRD.

@marun
Copy link
Contributor

marun commented Aug 8, 2019

Have you considered using a RawExtension field and adding mutator/accessor methods on the type to convert to/from unstructured?

@muvaf
Copy link
Contributor Author

muvaf commented Aug 9, 2019

I haven't yet. If we have to change the type of the field, this will require an interface change on our CRDs though, so, it'd be awesome if we can get the Unstructured type to work somehow.

muvaf added a commit to muvaf/crossplane that referenced this issue Aug 9, 2019
Unstructured type as CR field type. See kubernetes-sigs/controller-tools#301
- Leave comment about being able to use only LabelSelector field

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
hasheddan pushed a commit to muvaf/crossplane that referenced this issue Aug 9, 2019
Unstructured type as CR field type. See kubernetes-sigs/controller-tools#301
- Leave comment about being able to use only LabelSelector field

Signed-off-by: Muvaffak Onus <onus.muvaffak@gmail.com>
@hasheddan
Copy link

Updating the link referenced above to the *unstructure.Unstructured field.

displague added a commit to displague/crossplane that referenced this issue Aug 23, 2019
Controller-tools v0.2.0 removes our need to use the custom fork since kubernetes-sigs/controller-tools#301 has been released in v0.2.0.

Additionally, there are some features present in the v0.2.0 release that
were not in the beta.5 release, such as `controller-gen crd:maxDescLen=0` which may prove useful to address crossplane#698

Signed-off-by: Marques Johansson <marques@upbound.io>
displague added a commit to displague/crossplane that referenced this issue Aug 23, 2019
Controller-tools v0.2.0 removes our need to use the custom fork since kubernetes-sigs/controller-tools#301 has been released in v0.2.0.

Additionally, there are some features present in the v0.2.0 release that
were not in the beta.5 release, such as `controller-gen crd:maxDescLen=0` which may prove useful to address crossplane#698

Signed-off-by: Marques Johansson <marques@upbound.io>
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

Successfully merging a pull request may close this issue.

3 participants