Skip to content

Conversation

@mdbooth
Copy link
Contributor

@mdbooth mdbooth commented Nov 7, 2025

Adds a set of example which demonstrate the effects of escaping when generating validation rules. Specifically:

  • `` vs "" for rule quoting
  • "" vs r'' in CEL expressions

These tests justify the following general recommendations to avoid complex escaping:

  • Always prefer `` for validation rules
  • Always prefer r'' for strings in CEL expressions

@openshift-ci-robot
Copy link

Pipeline controller notification
This repository is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.

For optional jobs, comment /test ? to see a list of all defined jobs. Review these jobs and use /test <job> to manually trigger optional jobs most likely to be impacted by the proposed changes.

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

Hello @mdbooth! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 7, 2025
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign deads2k 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

Adds a set of example which demonstrate the effects of escaping when
generating validation rules. Specifically:

* `` vs "" for rule quoting
* "" vs r'' in CEL expressions

These tests justify the following general recommendations to avoid
complex escaping:

* Always prefer `` for validation rules
* Always prefer r'' for strings in CEL expressions
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Nov 7, 2025

@mdbooth: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/lint 73fa333 link true /test lint

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@mdbooth
Copy link
Contributor Author

mdbooth commented Nov 10, 2025

@JoelSpeed The linter is rejecting because apparently Pattern is banned in this repo. That obviously make this example impossible to write.

However, I also don't think it's a good idea. Certainly CEL has a lot of validation functions which we should require folks to use in preference to custom patterns. And as discussed, format markers in preference to those with the security related carve-outs documents in #2574. But if you're validating something that doesn't follow a standard kubernetes pattern then using Pattern is clearer and more concise than doing the same thing in a CEL expression. Quite apart from anything else, as demonstrated in this PR there are fewer escaping-related footguns.

A quick grep for Pattern in this repo shows that most, but critically far from all, of them should not exist.

Not sure what to do with this. My recommendation would be to remove the prohibition on Pattern and replace it with a softer review requirement that it needs a good use case. If you really want to stick with a ban then I'd also have to update #2574 to document that, as well as removing it here.

@openshift-merge-robot
Copy link
Contributor

PR needs rebase.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants