mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-02-14 18:09:58 +00:00
fix: inverted logic in forbidden user namespace metadata
This commit is contained in:
@@ -131,26 +131,36 @@ func (r *userMetadataHandler) OnUpdate(client client.Client, decoder *admission.
|
||||
}
|
||||
}
|
||||
|
||||
var labels, annotations map[string]string
|
||||
labels, annotations := oldNs.GetLabels(), oldNs.GetAnnotations()
|
||||
|
||||
for key, value := range newNs.GetLabels() {
|
||||
if _, ok := oldNs.GetLabels()[key]; ok {
|
||||
if labels == nil {
|
||||
labels = make(map[string]string)
|
||||
}
|
||||
|
||||
v, ok := labels[key]
|
||||
if !ok {
|
||||
labels[key] = value
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if v != value {
|
||||
continue
|
||||
}
|
||||
|
||||
delete(labels, key)
|
||||
}
|
||||
|
||||
for key, value := range newNs.GetAnnotations() {
|
||||
if _, ok := oldNs.GetAnnotations()[key]; ok {
|
||||
if annotations == nil {
|
||||
annotations = make(map[string]string)
|
||||
}
|
||||
|
||||
v, ok := annotations[key]
|
||||
if !ok {
|
||||
annotations[key] = value
|
||||
|
||||
continue
|
||||
}
|
||||
|
||||
if v != value {
|
||||
continue
|
||||
}
|
||||
|
||||
delete(annotations, key)
|
||||
}
|
||||
|
||||
return r.validateUserMetadata(tnt, recorder, labels, annotations)
|
||||
|
||||
Reference in New Issue
Block a user