-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
envtest: no matches for kind "Infrastructure" in version "config.openshift.io/v1" #1191
Comments
I was also facing this issue without much indication what the problem was - I think I've just realized the problem, maybe someone can correct me if I have it wrong: You are registering the object types with your But there is nothing to define the rest of those types with the apiserver (registering Go types with your scheme does not install the associated CRD, it's only telling your local client how to handle that type of object). For this to work the way you are expecting I think you would need to include the CRDs and add them to that list - otherwise the test apiserver will always return an error when you send a request for a type it hasn't heard of. Hope that helps. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Any updates on this? Getting the same error. Using go mod vendor won't help because non go files are pruned. Apart from crd paths, the environment has an attibute CRDs that looks promising but having issues using it since I can't find any documentation around it . Maybe @camilamacedo86 can shed some light? |
For those running into this, here's how to properly add the external crd manifests to envtest: CRDDirectoryPaths: []string{
filepath.Join("..", "config", "crd", "bases"),
filepath.Join(build.Default.GOPATH, "pkg", "mod", "github.com", "owner", "theirs@version", "config", "crd", "bases"),
}, |
Hi @hfgbarrigas, Just to confirm. We can close this one since the error here was solved. by adding the correct path for the CRDs. Am I right? |
Hi @camilamacedo86, I'd be inclined to close it. Though some documentation on how to do it and why using go modules would nice for future reference. |
This would be a nice FAQ entry. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-contributor-experience at kubernetes/community. |
Rotten issues close after 30d of inactivity. Send feedback to sig-contributor-experience at kubernetes/community. |
@fejta-bot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@camilamacedo86 Where can I find OpenShift Route CRD? |
@avrahams There is a manual way though. One has to create a 'fake' CRD within the correct OCP API repository path and adapt the make targets. E.g. for apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
# name must be in the form: <plural>.<group>
# <group> has to match the correspondig .spec field
name: routes.route.openshift.io
spec:
# group name to use for REST API: /apis/<group>/<version>
group: route.openshift.io
versions:
- name: v1
served: true
storage: true
scope: Namespaced
subresources:
# enable spec/status
status: {}
names:
plural: routes
singular: route
kind: Route Then the $(call add-crd-gen,route,./route/v1,./route/v1,./route/v1) Updating the CRDs with make update-codegen-crds populates the CRD stub with the correct OpenAPI validation content. Unfortunately it seems to only works this way, as the API repo infrastructure already expects the basic CRD to be there (I am sure one can work around that somehow). It works for other resources as well, but it is obviously not a very practical solution. So this is just a documentation comment for people experiencing similar problems with OCP related resources. Just as a warning: In some of my tests I experienced validation errors populating |
Thank you @mpreu this worked |
Dependency versions:
sigs.k8s.io/controller-runtime v0.6.3
github.com/openshift/api v0.0.0-20200326152221-912866ddb162
I'm getting the error above in my test even though I've added the relevant schema like so:
I have some other schemas I've added including the one for our CRD, and those don't give me problems. The controller does start and begins reconciling our CRD. I also checked the version of the OpenShift API that I'm using to make sure it has
Infrastructure
and it does: https://pkg.go.dev/github.com/openshift/[email protected]/config/v1Am I missing something else? Full code is here: https://github.com/IBM/starter-kit-operator/blob/operator-sdk-upgrade/controllers/suite_test.go
The text was updated successfully, but these errors were encountered: