Skip to content

Conversation

@LoginovIlia
Copy link

What this PR does

Adds validation for the pattern field when a pattern is added or changed. Removing a pattern is still allowed

Rationale

Changing or adding a regex may block values that worked before, so we mark these changes. Removing a regex makes the input more open, so we do not mark it

Changes

  • Adds validation in pkg/validations/property/pattern.go with unit tests
  • Adds a new section to docs/validations.md
  • Adds e2e tests: test/patternadded and test/patternchanged

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Sep 25, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: LoginovIlia
Once this PR has been reviewed and has the lgtm label, please assign joelspeed for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot
Copy link
Contributor

Welcome @LoginovIlia!

It looks like this is your first PR to kubernetes-sigs/crdify 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/crdify has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Sep 25, 2025
@LoginovIlia
Copy link
Author

/cc @jpbetz

@everettraven
Copy link
Contributor

Just a heads up that this is on my list to take a look at soon. If I don't get to it today, it will be on my list for first thing next week. Thanks for contributing!

Copy link
Contributor

@everettraven everettraven left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, this looks really good - thanks for taking the time to contribute!

I'm requesting changes here because of some recent conversations I've had with folks that brought to my attention the importance of taking into account how loosening validations may impact both readers and writers of an API.

Because crdify doesn't have nuanced knowledge of a situation, we should add a knob here so that users of crdify that do not want to allow removal of a pattern constraint can do so and we should default to that behavior (we always default to the most restrictive at the moment).

Validates compatibility of changes to a property's pattern regular expression. Adding a pattern
that did not previously exist or modifying the expression can tighten validation, so these changes
are flagged for review. Removing a pattern is accepted because it broadens what values are allowed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to allow users to restrict removal of a pattern as well (and maybe we default to restricting this too).

Removing a pattern is a compatible change for writers, but is likely a breaking change to readers.

Older clients may no longer be able to handle the values here if they were built on the assumption that valid values for that field always adhere to that pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants