-
Notifications
You must be signed in to change notification settings - Fork 38.7k
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
refactor: annotation key validation should be unified #109588
Conversation
Please note that we're already in Test Freeze for the |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: pandaamanda 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 |
/retest |
2 similar comments
/retest |
/retest |
refactor: annotation key validation should be unified
0355ecf
to
2912190
Compare
/assign @Jefftree can you please cc the right people for validation. Thanks! |
@@ -910,6 +910,7 @@ func NewMutatingTestCases(url *url.URL, configurationName string) []MutatingTest | |||
"mutation.webhook.admission.k8s.io/round_0_index_1": mutationAnnotationValue(configurationName, "removeLabel", true), | |||
"patch.webhook.admission.k8s.io/round_0_index_0": patchAnnotationValue(configurationName, "addLabel", `[{"op": "add", "path": "/metadata/labels/added", "value": "test"}]`), | |||
"patch.webhook.admission.k8s.io/round_0_index_1": patchAnnotationValue(configurationName, "removeLabel", `[{"op": "remove", "path": "/metadata/labels/remove"}]`), | |||
"removeLabel/key1": "value1", |
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.
Do you know who set this label? Was it failing silently before this change?
@@ -204,7 +204,7 @@ func checkKeyFormat(key string) error { | |||
if len(parts) != 2 { | |||
return fmt.Errorf("annotation key has invalid format, the right format is a DNS subdomain prefix and '/' and key name. (e.g. 'podsecuritypolicy.admission.k8s.io/admit-policy')") | |||
} | |||
if msgs := validation.IsQualifiedName(key); len(msgs) != 0 { | |||
if msgs := validation.IsQualifiedName(strings.ToLower(key)); len(msgs) != 0 { |
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.
The validation in metadata.annotation is a little confusing today #109892. Not sure if we should change the validation in audit annotation to match that, or simply improve our documentation.
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.
ok, i will close it.
tks
/close |
What type of PR is this?
/kind cleanup
What this PR does / why we need it:
Which issue(s) this PR fixes:
Fixes #
annotation key support uppercase letter,validate logic should be unified.
kubernetes/staging/src/k8s.io/apimachinery/pkg/api/validation/objectmeta.go
Lines 46 to 53 in f173d01
Special notes for your reviewer:
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.: