I'd like to know if the client-go library for Kubernetes contains a function that validates if a json/yaml file. Ideally, it would catch errors such as names not being a DNS-1123 compliant or invalid fields specified. It would also be ideal if a list of errors was returned as opposed to the function returning after the first error encountered.
One thought I have tried is doing an exec to call kubectl --validate --dry-run
but this does not fully validate a manifest (meaning it's possible to pass here but fail when you actually apply the file). It also stops at the first error. Plus, it would get expensive quickly if you have a list of manifests to go through.
Another option I looked at was here Kubernetes GitHub Issue 193 but that's not really the appropriate function nor does it do the checks I'm looking for.
Client-go library for Kubernetes contains no validation functions for YAML/JSON configuration files.
But take a look at this utiliy, you can use it for validation on a client’s side and also use its code as an example of validation implementation.