instrumenta / kubernetes-json-schema

Schemas for every version of every object in every version of Kubernetes
https://kubernetesjsonschema.dev
Other
306 stars 134 forks source link

Object with required fields can be null #25

Open yannh opened 4 years ago

yannh commented 4 years ago

Some objects with fields marked as required can be null, if I understand this correctly this should not be the case and can result in JSONs missing required fields being marked as valid.

For example this here: https://github.com/instrumenta/kubernetes-json-schema/blob/133f84871ccf6a7a7d422cc40e308ae1c044c2ab/v1.17.0-standalone-strict/cronjob.json#L220-L229

I believe it might come from this line https://github.com/instrumenta/openapi2jsonschema/blob/d697cbff8a25f520e125e3a5f79cb4e9b972e8ce/openapi2jsonschema/util.py#L67 - I am not sure to understand why the last condition is there?

jcmcken commented 3 years ago

We also have this issue, and our users are hitting this problem often. kubeval allows a config file to pass that, for example, will panic Kustomize or fail if you try to kubectl apply it. Kustomize, for its own part, does not have a very good error message when it has problems like this. But it seems strange to allow null values for fields which in the upstream API spec must take values.