Ask questionsenvtest: no matches for kind "Infrastructure" in version ""

Dependency versions: v0.6.3 v0.0.0-20200326152221-912866ddb162

I'm getting the error above in my test even though I've added the relevant schema like so:

	configv1 ""
var _ = BeforeSuite(func(done Done) {
	err = configv1.AddToScheme(scheme.Scheme)

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:

Am I missing something else? Full code is here:


Answer questions mpreu

@avrahams There is none for Route. All OCP related CRDs are potentially to be found in the API repo, but some of the "older" OCP resources are not published this way. Recently was in contact with some Red Hat people and my information so far is, that there is no really immediate plan to change that.

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 Routes, a CRD file route_crd.yaml with the following content has to be created in the path

kind: CustomResourceDefinition
  # name must be in the form: <plural>.<group>
  # <group> has to match the correspondig .spec field
  # group name to use for REST API: /apis/<group>/<version>
    - name: v1
      served: true
      storage: true
  scope: Namespaced
    # enable spec/status
    status: {}
    plural: routes
    singular: route
    kind: Route

Then the Makefile has to get this line:

$(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 envtest with these CRDs, but I did not investigate it further.

Matthias Preu mpreu Cariad SE (Volkswagen Group) Wolfsburg, Germany Solution-Architect with focus on cloud-native development for Kubernetes and Red Hat OpenShift.
Github User Rank List