The canonical location of the Open Cluster Management API definition.
If you make a change to a CRD type in this repo, calling make update-codegen-crds
should regenerate all CRDs and update the manifests. If yours is not updated, ensure that the path to its API is included in our calls to the Makefile targets.
To add this generator to another repo:
-
Vendor
github.com/openshift/library-go
(and ensure that thealpha-build-machinery
subdirectory is also included in yourvendor
) -
Update your
Makefile
to include the following:
include $(addprefix ./vendor/github.com/openshift/library-go/alpha-build-machinery/make/, \
targets/openshift/crd-schema-gen.mk \
)
$(call add-crd-gen,<TARGET_NAME>,<API_DIRECTORY>,<CRD_MANIFESTS>,<MANIFEST_OUTPUT>)
The parameters for the call are:
TARGET_NAME
: The name of your generated Make target. This can be anything, as long as it does not conflict with another make target. Recommended to be your api name.API_DIRECTORY
: The location of your API. For example if your Go types are located underpkg/apis/myoperator/v1/types.go
, this should be./pkg/apis/myoperator/v1
.CRD_MANIFESTS
: The directory your CRDs are located in. For example, if that ismanifests/my_operator.crd.yaml
then it should be./manifests
MANIFEST_OUTPUT
: This should most likely be the same asCRD_MANIFESTS
, and is only provided for flexibility to output generated code to a different directory.
You can include as many calls to different APIs as necessary, or if you have multiple APIs under the same directory (eg, v1
and v2beta1
) you can use 1 call to the parent directory pointing to your API.
After this, calling make update-codegen-crds
should generate a new structural OpenAPIV3 schema for your CRDs.
Notes
- This will not generate entire CRDs, only their OpenAPIV3 schemas. If you do not already have a CRD, you will get no output from the generator.
- Ensure that your API is correctly declared for the generator to pick it up. That means, in your
doc.go
, include the following:// +groupName=<API_GROUP_NAME>
, this should match thegroup
in your CRDspec
// +kubebuilder:validation:Optional
, this tells the operator that fields should be optional unless explicitly marked with// +kubebuilder:validation:Required
For more information on the API markers to add to your Go types, see the Kubebuilder book