java
java copied to clipboard
question: how to use crd-model-gen image to generate Java classes from CRD YAMLs with `x-kubernetes-validations`?
trafficstars
Hi, I'm using ghcr.io/kubernetes-client/java/crd-model-gen:v1.0.6 to generate Java classes from K8s CRD YAMLs. My YAML has x-kubernetes-validations. Currently I'm getting the following error.
docker run \
--rm \
-v "$LOCAL_MANIFEST_FILE":"$LOCAL_MANIFEST_FILE" \
-v /var/run/docker.sock:/var/run/docker.sock \
-v "$(pwd)":"$(pwd)" \
--network host \
ghcr.io/kubernetes-client/java/crd-model-gen:v1.0.6 \
/generate.sh \
-u "$LOCAL_MANIFEST_FILE" \
-n com.example \
-p com.example.foo \
--validate=false \
-o "$(pwd)/target/generated-sources"
error: error validating "/home/dxia/src/com.example/foo/foo-api/foo.yaml": error validating data: ValidationError(CustomResourceDefinition.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.resources.properties.storage): unknown field "x-kubernetes-validations" in io.k8s.apiextensions-apiserver.pkg.apis.apiextensions.v1.JSONSchemaProps; if you choose to ignore these errors, turn validation off with --validate=false
I tried adding --validate=false to the docker run args, but it looks like the executable in the image only supports the following args based on this new error.
[INFO] --- exec-maven-plugin:3.0.0:exec (run-generate-java-script) @ workbench-api ---
find: ‘target/generated-sources/src/main/java/com/example/foo/api/models’: No such file or directory
/generate.sh: illegal option -- -
Usage: generate Java model classes from CRDs
-n: the prefix of the target CRD's api group to generate.
-p: the base package name of the generated java project.
-o: output directory of the generated java project.
-u: url location of the YAML manifest to install CRDs to a Kubernetes cluster.
[ERROR] Command execution failed.
my questions
- Is
crd-model-genimage meant to be public or internal to this repo only? - If it's meant to be public, any way to support
x-kubernetes-validationsor to disable this validation? - Any plans to support generating classes from CRD YAMLs with
x-kubernetes-validations?