Add a `crossplane lint xrd.yaml` command
What problem are you facing?
https://github.com/crossplane/docs/issues/564 tracks documenting best practices for API design. Put otherwise, best practices for writing XRDs. It occurred to me today that we could probably write a linter for a lot of these.
It could make sense for this to be part of crossplane beta validate too, but I think validation and linting are slightly different things. An XRD could have a valid OpenAPI schema, but one that we wouldn't recommend.
How could Crossplane help solve your problem?
Add a linter for XRDs. Some things to look for:
- Overly restrictive status fields. Status fields aren't written by users, so they typically shouldn't be required, or generally validated beyond their type (e.g maximum integers, etc).
- Arrays of objects missing a
namefield. - Boolean fields, which Kubernetes API conventions would typically recommend be enums.
- Missing server-side apply merge OpenAPI extensions where we'd expect them.
- General OpenAPI hygiene - fields missing descriptions etc
crossplane lint --old=old-xrd.yaml new-xrd.yaml
If we supported linting XRD changes we could also look for breaking changes, e.g:
- Introducing new required fields.
- Making required fields optional.
- Renaming fields without introducing a new version.
Prior art: https://github.com/openshift/crd-schema-checker/
Would love to have something like this
@Cliftonz add a 👍 to help us prioritize issues. Thanks!
Crossplane does not currently have enough maintainers to address every issue and pull request. This issue has been automatically marked as stale because it has had no activity in the last 90 days. It will be closed in 14 days if no further activity occurs. Leaving a comment starting with /fresh will mark this issue as not stale.
/fresh