From c7e2cb13d9ee2d931f540ade5359315e609f2454 Mon Sep 17 00:00:00 2001 From: Mariam Fahmy Date: Wed, 15 Nov 2023 14:04:45 +0200 Subject: [PATCH] fix: use v2beta1 version of exceptions in kyverno create CLI (#8908) Signed-off-by: Mariam Fahmy --- .../kubectl-kyverno/commands/create/exception/command.go | 7 +++---- .../commands/create/exception/command_test.go | 4 ++-- .../commands/create/templates/exception.yaml | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/cli/kubectl-kyverno/commands/create/exception/command.go b/cmd/cli/kubectl-kyverno/commands/create/exception/command.go index 7d20311cbb..115e89706c 100644 --- a/cmd/cli/kubectl-kyverno/commands/create/exception/command.go +++ b/cmd/cli/kubectl-kyverno/commands/create/exception/command.go @@ -7,7 +7,6 @@ import ( "text/template" kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1" - "github.com/kyverno/kyverno/api/kyverno/v2alpha1" "github.com/kyverno/kyverno/api/kyverno/v2beta1" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/command" "github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/commands/create/templates" @@ -18,7 +17,7 @@ type options struct { Name string Namespace string Background bool - Exceptions []v2alpha1.Exception + Exceptions []v2beta1.Exception Match v2beta1.MatchResources } @@ -81,12 +80,12 @@ func Command() *cobra.Command { return cmd } -func parseRule(in string) *v2alpha1.Exception { +func parseRule(in string) *v2beta1.Exception { parts := strings.Split(in, ",") if len(parts) < 2 { return nil } - return &v2alpha1.Exception{ + return &v2beta1.Exception{ PolicyName: parts[0], RuleNames: parts[1:], } diff --git a/cmd/cli/kubectl-kyverno/commands/create/exception/command_test.go b/cmd/cli/kubectl-kyverno/commands/create/exception/command_test.go index deed709e95..948bb2d716 100644 --- a/cmd/cli/kubectl-kyverno/commands/create/exception/command_test.go +++ b/cmd/cli/kubectl-kyverno/commands/create/exception/command_test.go @@ -40,7 +40,7 @@ func TestCommandWithAny(t *testing.T) { out, err := io.ReadAll(b) assert.NoError(t, err) expected := ` -apiVersion: kyverno.io/v2alpha1 +apiVersion: kyverno.io/v2beta1 kind: PolicyException metadata: name: test @@ -73,7 +73,7 @@ func TestCommandWithAll(t *testing.T) { out, err := io.ReadAll(b) assert.NoError(t, err) expected := ` -apiVersion: kyverno.io/v2alpha1 +apiVersion: kyverno.io/v2beta1 kind: PolicyException metadata: name: test diff --git a/cmd/cli/kubectl-kyverno/commands/create/templates/exception.yaml b/cmd/cli/kubectl-kyverno/commands/create/templates/exception.yaml index 8e1725e548..324ab053b0 100644 --- a/cmd/cli/kubectl-kyverno/commands/create/templates/exception.yaml +++ b/cmd/cli/kubectl-kyverno/commands/create/templates/exception.yaml @@ -1,4 +1,4 @@ -apiVersion: kyverno.io/v2alpha1 +apiVersion: kyverno.io/v2beta1 kind: PolicyException metadata: name: {{ .Name }}