yannh / kubeconform

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

Suggestion: support skipping version #169

Open levenleven opened 1 year ago

levenleven commented 1 year ago

Currently -skip allows providing a kind or version/kind

https://github.com/yannh/kubeconform/blob/ee7c49858007a5644743c458fb31113c0d6a921c/pkg/validator/validator.go#L107-L111

In some cases it would be handy to be able to skip all resources from the api version altogether e.g.

-skip networking.istio.io/v1alpha3

instead of skipping kinds one by one like

-skip networking.istio.io/v1alpha3/DestinationRule,networking.istio.io/v1alpha3/VirtualService

Would you accept PR introducing such functionality?

yannh commented 1 year ago

Hi, could you maybe provide a diff to the "Usage" documentation to explain how you would see this being used first? Thanks!

levenleven commented 1 year ago

👋 Thanks for looking into this, I've updated the description hopefully it makes sense now. So basically the suggestion is to allow skipping the apiVersion.

Before:

-skip string
      comma-separated list of kinds or GVKs to ignore

After:

-skip string
      comma-separated list of kinds, api versions or GVKs to ignore
wrdls commented 1 year ago

Would like to see support for this as well.

My use case is with Gatekeeper.

This allows you to create OPA policies by first creating a templates.gatekeeper.sh/v1/ConstraintTemplate resource which contains a OpenAPIV3Schema schema and then one or more constraints.gatekeeper.sh/v1beta1/<MY_CUSTOM_CONSTRAINT> resources based on that template.

See https://open-policy-agent.github.io/gatekeeper/website/docs/howto#constraint-templates

I would like to ignore all constraints.gatekeeper.sh/v1beta1 because it's pretty much impossible to keep our schemas up to date with those constraint resources (or the list for -skip).