mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-19 08:40:42 +00:00
Skip namespace selector evaluation for 'select all' selectors
This commit is contained in:
parent
4fed75302a
commit
e068a98f4f
@ -95,6 +95,15 @@ func (m *Matcher) MatchNamespaceSelector(h *v1beta1.Webhook, attr admission.Attr
|
|||||||
// Also update the comment in types.go
|
// Also update the comment in types.go
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
// TODO: adding an LRU cache to cache the translation
|
||||||
|
selector, err := metav1.LabelSelectorAsSelector(h.NamespaceSelector)
|
||||||
|
if err != nil {
|
||||||
|
return false, apierrors.NewInternalError(err)
|
||||||
|
}
|
||||||
|
if selector.Empty() {
|
||||||
|
return true, nil
|
||||||
|
}
|
||||||
|
|
||||||
namespaceLabels, err := m.GetNamespaceLabels(attr)
|
namespaceLabels, err := m.GetNamespaceLabels(attr)
|
||||||
// this means the namespace is not found, for backwards compatibility,
|
// this means the namespace is not found, for backwards compatibility,
|
||||||
// return a 404
|
// return a 404
|
||||||
@ -108,10 +117,5 @@ func (m *Matcher) MatchNamespaceSelector(h *v1beta1.Webhook, attr admission.Attr
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return false, apierrors.NewInternalError(err)
|
return false, apierrors.NewInternalError(err)
|
||||||
}
|
}
|
||||||
// TODO: adding an LRU cache to cache the translation
|
|
||||||
selector, err := metav1.LabelSelectorAsSelector(h.NamespaceSelector)
|
|
||||||
if err != nil {
|
|
||||||
return false, apierrors.NewInternalError(err)
|
|
||||||
}
|
|
||||||
return selector.Matches(labels.Set(namespaceLabels)), nil
|
return selector.Matches(labels.Set(namespaceLabels)), nil
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user