Validate schema between CRD versions and detect breaking changes

1 skarlso 1 6/26/2025, 12:52:01 PM github.com ↗

Comments (1)

skarlso · 8h ago
Hello everyone!

My project [crd-to-sample-yaml](https://github.com/Skarlso/crd-to-sample-yaml) just got a neat new feature. It's validation of schemas between versions for a CRD. What the heck do I mean here?

TL;DR: Things like modifying required fields, removing existing fields, increasing minimum etc, all cause breaking changes between versions. That's what this can detect and show.

Longer:

So the project already had a testing feature like helm, but it wasn't this direct. And this command now can more easily be integrated as a CLI checker for between specific versions. Something like this:

``` cty validate schema -c path/to/crd.yaml --from v1alpha1 --to v1beta1 --fail-on-breaking ```

And it, of course, works with all the providers that it supports ( github, url, oci, files, folders... ).

The output is something like this:

``` Schema Validation Report =======================

CRD: TestResource From Version: v1alpha1 To Version: v1beta1

Summary: Total Changes: 5 Breaking Changes: 2 Additions: 2 Removals: 0

Changes: [breaking] spec.required: Field 'version' is now required + [addition] spec.properties.version: Property 'version' added [breaking] spec.properties.count.minimum: Minimum increased Old: 1 New: 5 ```

Or JSON, or YAML for further processing or putting the output into a Release Note.

I hope this is useful, it was very interesting to write it at least. :)

Enjoy it here [v1.2.0 release page](https://github.com/Skarlso/crd-to-sample-yaml/releases/tag/v...) and there is more documentation in [Schema validation doc](https://github.com/Skarlso/crd-to-sample-yaml/blob/main/SCHE...).

Thanks!