Skip to content

Commit

Permalink
fix: add the support of v2alpha1 exceptions in the CLI (kyverno#9714)
Browse files Browse the repository at this point in the history
Signed-off-by: Mariam Fahmy <[email protected]>
  • Loading branch information
MariamFahmy98 authored Feb 12, 2024
1 parent bd37cbb commit 31bb107
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cmd/cli/kubectl-kyverno/exception/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"path/filepath"

kyvernov2 "github.com/kyverno/kyverno/api/kyverno/v2"
kyvernov2alpha1 "github.com/kyverno/kyverno/api/kyverno/v2alpha1"
kyvernov2beta1 "github.com/kyverno/kyverno/api/kyverno/v2beta1"
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/data"
"github.com/kyverno/kyverno/ext/resource/convert"
Expand All @@ -16,9 +17,10 @@ import (
)

var (
factory, _ = resourceloader.New(openapiclient.NewComposite(openapiclient.NewLocalCRDFiles(data.Crds(), data.CrdsFolder)))
exceptionV2beta1 = schema.GroupVersion(kyvernov2beta1.GroupVersion).WithKind("PolicyException")
exceptionV2 = schema.GroupVersion(kyvernov2.GroupVersion).WithKind("PolicyException")
factory, _ = resourceloader.New(openapiclient.NewComposite(openapiclient.NewLocalCRDFiles(data.Crds(), data.CrdsFolder)))
exceptionV2alpha1 = schema.GroupVersion(kyvernov2alpha1.GroupVersion).WithKind("PolicyException")
exceptionV2beta1 = schema.GroupVersion(kyvernov2beta1.GroupVersion).WithKind("PolicyException")
exceptionV2 = schema.GroupVersion(kyvernov2.GroupVersion).WithKind("PolicyException")
)

func Load(paths ...string) ([]*kyvernov2beta1.PolicyException, error) {
Expand Down Expand Up @@ -49,7 +51,7 @@ func load(content []byte) ([]*kyvernov2beta1.PolicyException, error) {
return nil, err
}
switch gvk {
case exceptionV2beta1, exceptionV2:
case exceptionV2alpha1, exceptionV2beta1, exceptionV2:
exception, err := convert.To[kyvernov2beta1.PolicyException](untyped)
if err != nil {
return nil, err
Expand Down

0 comments on commit 31bb107

Please sign in to comment.