yannh / kubeconform

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

add x-kubernetes-preserve-unknown-fields handling #225

Closed FrancoisPoinsot closed 7 months ago

FrancoisPoinsot commented 1 year ago

skip setting "additionalProperties: false" when x-kubernetes-preserve-unknown-fields == true

This should implement the behavior of https://kubernetes.io/docs/tasks/extend-kubernetes/custom-resources/custom-resource-definitions/#controlling-pruning

fixes https://github.com/yannh/kubeconform/issues/224

FrancoisPoinsot commented 10 months ago

Hey @yannh Is that PR a thing you would be interested in?

yannh commented 10 months ago

Hi @FrancoisPoinsot ! So the issue if I understand it correctly, is that the behavior set by --strict can be overriden in-schema for certain fields, with x-kubernetes-preserve-unknown-fields being set to true or false?

FrancoisPoinsot commented 10 months ago

correct

yannh commented 9 months ago

Hi @FrancoisPoinsot , sorry for the delayed response - any chance to add a test to ensure this works and doesn't break in the future? Otherwise it looks good to me.

FrancoisPoinsot commented 9 months ago

I will be honest, I am not super familiar with python I will try to see what I can do But if you already have some idea in mind, don't hesitate to add a commit to that PR.

FrancoisPoinsot commented 9 months ago

I see 2 suites of test.

One at the root, called with

make docker-build-static
make docker-acceptance

The other under /scripts.

The first one has more scenario but only the second one is called from github action.

Which one should I extend?

edit: Forget that, I see the test for openapi2jsonschema.py is the one under /scripts

FrancoisPoinsot commented 9 months ago

Added a couple of test. 1 in /scripts to check the generated schema remains the same. 1 at the root to check an emissary Mapping. This is one of the custom resources I had trouble with originaly.

@yannh , does that look alright to you?

FrancoisPoinsot commented 7 months ago

@yannh should I close that PR?