mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-07 00:17:13 +00:00
32 lines
1.1 KiB
Go
32 lines
1.1 KiB
Go
package engine
|
|
|
|
import (
|
|
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
|
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/apimachinery/pkg/labels"
|
|
)
|
|
|
|
type matchCriteria struct {
|
|
constraints *admissionregistrationv1.MatchResources
|
|
}
|
|
|
|
// GetParsedNamespaceSelector returns the converted LabelSelector which implements labels.Selector
|
|
func (m *matchCriteria) GetParsedNamespaceSelector() (labels.Selector, error) {
|
|
if m.constraints.NamespaceSelector == nil {
|
|
return labels.Everything(), nil
|
|
}
|
|
return metav1.LabelSelectorAsSelector(m.constraints.NamespaceSelector)
|
|
}
|
|
|
|
// GetParsedObjectSelector returns the converted LabelSelector which implements labels.Selector
|
|
func (m *matchCriteria) GetParsedObjectSelector() (labels.Selector, error) {
|
|
if m.constraints.ObjectSelector == nil {
|
|
return labels.Everything(), nil
|
|
}
|
|
return metav1.LabelSelectorAsSelector(m.constraints.ObjectSelector)
|
|
}
|
|
|
|
// GetMatchResources returns the matchConstraints
|
|
func (m *matchCriteria) GetMatchResources() admissionregistrationv1.MatchResources {
|
|
return *m.constraints
|
|
}
|