Skip to content

Add CEL validation for object names - #4280

Merged
caseydavenport merged 2 commits into
tigera:masterfrom
caseydavenport:casey-name-validation
Dec 9, 2025
Merged

caseydavenport merged 2 commits into
tigera:masterfrom
caseydavenport:casey-name-validation

Conversation

@caseydavenport

@caseydavenport caseydavenport commented Dec 3, 2025 •

Copy link
Copy Markdown
Member

Description

We can use CEL validation to enforce the singleton nature of many of our CRs.

This is hopefully the first of many CEL improvements we can make to our
API validation.

xref: https://kubernetes.io/docs/reference/using-api/cel/

Release Note

Use CEL validation for CR names. 

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files
  • If changing versions, run make gen-versions

For PR reviewers

A note for code reviewers - all pull requests must have the following:

  • Milestone set according to targeted release.
  • Appropriate labels:
    • kind/bug if this is a bugfix.
    • kind/enhancement if this is a a new feature.
    • enterprise if this PR applies to Calico Enterprise only.

Comment thread api/v1/installation_types.go Resolved
Comment thread api/v1/gatewayapi_types.go Resolved
Comment thread api/v1/authentication_types.go Resolved

@tmjd tmjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

A couple comments, I like the tests, those are nice and simple.

Comment thread api/v1/installation_types.go Resolved
Comment thread test/validation_test.go Resolved
@caseydavenport
caseydavenport requested a review from tmjd December 8, 2025 18:37
@caseydavenport

Copy link
Copy Markdown
Member Author

@tmjd thanks for the review! Pushed a commit to address your two comments

@tmjd tmjd left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would have been ok keeping the defer in the test code, I just didn't understand why it was there. Feel free to add it back if you'd like.

@caseydavenport
caseydavenport merged commit 73cfac4 into tigera:master Dec 9, 2025
6 checks passed
@caseydavenport
caseydavenport deleted the casey-name-validation branch December 9, 2025 18:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants