mirror of
https://github.com/kyverno/kyverno.git
synced 2024-12-14 11:57:48 +00:00
94d9bbe73f
Signed-off-by: Mariam Fahmy <mariam.fahmy@nirmata.com>
34 lines
699 B
Go
34 lines
699 B
Go
package exceptions
|
|
|
|
import (
|
|
kyvernov2 "github.com/kyverno/kyverno/api/kyverno/v2"
|
|
"k8s.io/apimachinery/pkg/labels"
|
|
)
|
|
|
|
type Lister interface {
|
|
List(labels.Selector) ([]*kyvernov2.PolicyException, error)
|
|
}
|
|
|
|
type selector struct {
|
|
lister Lister
|
|
}
|
|
|
|
func New(lister Lister) selector {
|
|
return selector{
|
|
lister: lister,
|
|
}
|
|
}
|
|
|
|
func (s selector) Find(policyName string, ruleName string) ([]*kyvernov2.PolicyException, error) {
|
|
polexs, err := s.lister.List(labels.Everything())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
var results []*kyvernov2.PolicyException
|
|
for _, polex := range polexs {
|
|
if polex.Contains(policyName, ruleName) {
|
|
results = append(results, polex)
|
|
}
|
|
}
|
|
return results, nil
|
|
}
|