yannh / kubeconform

A FAST Kubernetes manifests validator, with support for Custom Resources!
Apache License 2.0
2.15k stars 121 forks source link

"could not find schema" #180

Closed roy-work closed 1 year ago

roy-work commented 1 year ago

If I run a command such as,

kubeconform -schema-location default -schema-location ~/code/third-party/kubeconform/scripts/crds/ .charts

I get a lot of output, such as:

.charts/dev/certs/templates/acme-crt.yaml - Certificate acme-crt failed validation: could not find schema for Certificate

Now, the crds directory specified contains a bunch of schema files ("crds" is perhaps a bad name for the dir; they contain schemas, not CRDs):

» ~/tmp/venv/bin/python3 ../openapi2jsonschema.py ~/[snip]/.charts/[snip]/cert-manager/templates/crd-certificates.yaml
JSON schema written to certificate_v1alpha2.json
JSON schema written to certificate_v1alpha3.json
JSON schema written to certificate_v1beta1.json
JSON schema written to certificate_v1.json
± kubeconform:master:/scripts/crds
» ls
certificate_v1.json  certificate_v1alpha2.json  certificate_v1alpha3.json  certificate_v1beta1.json

So … why is the schema still not found?

eyarz commented 1 year ago

you're missing the file name from the schema location path so kubconform doesn't know which file to grab.

this is how the path should look in your case:

-schema-location default -schema-location ~/code/third-party/kubeconform/scripts/crds/{{.ResourceKind}}_{{.ResourceAPIVersion}}.json
yannh commented 1 year ago

Hi @roy-work , I suspect @eyarz might have found the right solution? :crossed_fingers: Closing this issue :bow: