Skip to content

Commit

Permalink
fix: policy exceptions selector with cluster (#380)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
  • Loading branch information
eddycharly committed Jun 1, 2023
1 parent ae69a52 commit bd62e2c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions backend/pkg/cluster/policy_exception.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
kyvernov2alpha1 "github.com/kyverno/kyverno/api/kyverno/v2alpha1"
"github.com/kyverno/kyverno/pkg/client/clientset/versioned"
engineapi "github.com/kyverno/kyverno/pkg/engine/api"
kerrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
)
Expand All @@ -22,12 +23,13 @@ func (c policyExceptionSelector) List(selector labels.Selector) ([]*kyvernov2alp
list, err := c.kyvernoClient.KyvernoV2alpha1().PolicyExceptions(c.namespace).List(context.TODO(), metav1.ListOptions{
LabelSelector: selector.String(),
})
if err != nil {
if err == nil {
for i := range list.Items {
exceptions = append(exceptions, &list.Items[i])
}
} else if !kerrors.IsNotFound(err) {
return nil, err
}
for i := range list.Items {
exceptions = append(exceptions, &list.Items[i])
}
}
for _, exception := range c.additional {
if c.namespace == "" || exception.GetNamespace() == c.namespace {
Expand Down

0 comments on commit bd62e2c

Please sign in to comment.