-
Notifications
You must be signed in to change notification settings - Fork 38
fix: add validation for CRP and PickFixed cluster names #1190
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
fix: add validation for CRP and PickFixed cluster names #1190
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds validation improvements for ClusterResourcePlacement (CRP) names and cluster names in PickFixed policies. The changes address issues found during bug bash testing by implementing proper DNS validation rules instead of simple length checks.
- Enhanced CRP name validation to use DNS-1035 label validation instead of just length validation
- Added validation for cluster names in PickFixed policies to ensure they follow DNS-1123 label format
- Updated test cases to reflect the new validation error messages and added coverage for invalid cluster names
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/utils/validator/clusterresourceplacement.go | Updated validation logic for CRP names and PickFixed cluster names with proper DNS validation |
| pkg/utils/validator/clusterresourceplacement_test.go | Updated test error messages and added new test case for invalid cluster names validation |
Signed-off-by: Nont <[email protected]>
866b3f5 to
3cc2eaf
Compare
| } | ||
| uniqueClusterNames := make(map[string]bool) | ||
| for _, name := range policy.ClusterNames { | ||
| nameErr := validation.IsDNS1123Label(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it should be IsDNS1123Subdomain and length(name) < 64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to what you suggested now.
Signed-off-by: Nont <[email protected]>
85d15f6 to
a7dfad3
Compare
Description of your changes
As a result from the latest bug bash, we want to introduce validations for:
I have:
make reviewableto ensure this PR is ready for review.How has this code been tested
Run unit tests and add new test cases for negative validation scenarios.