Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle validation #12

Open
3 tasks
clux opened this issue Nov 28, 2021 · 0 comments
Open
3 tasks

handle validation #12

clux opened this issue Nov 28, 2021 · 0 comments
Labels
help wanted Extra attention is needed

Comments

@clux
Copy link
Member

clux commented Nov 28, 2021

kube-derive supports using schemars + validator to inject validation rules into the schema.

We should similarly parse the validation attributes from the schema, and store them as properties on OutputMember, so we can (optionally) add them to the generated code. (See crd_api example for how the output is supposed to look (ignore the deprecation attrs)).

Fields to look for (that we currently do not cover):

  • exclusiveMaximum
  • exclusiveMinimum
  • maximum
  • maxItems
  • maxLength
  • minimum
  • minItems
  • minLength
  • multipleOf
  • pattern
  • uniqueItems

These are mentioned in the kubernetes crd docs.

Don't think we can verify all of them, but should be able to do min/max stuff + patterns with some of the basics from validator. Partial attempts at some of the properties is welcome.

At the very least this needs:

  • flags for OutputMember to store information found during analysis
  • --validation bool flag for cli to optionally enable it
  • crd with a test case for CI
@clux clux added the help wanted Extra attention is needed label Nov 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

1 participant