diff --git a/pkg/api/kyverno/v1/register.go b/pkg/api/kyverno/v1/register.go index e0c034e9d2..444c737e6c 100644 --- a/pkg/api/kyverno/v1/register.go +++ b/pkg/api/kyverno/v1/register.go @@ -9,7 +9,7 @@ import ( ) // SchemeGroupVersion is group version used to register these objects -var SchemeGroupVersion = schema.GroupVersion{Group: kyverno.GroupName, Version: "v1alpha1"} +var SchemeGroupVersion = schema.GroupVersion{Group: kyverno.GroupName, Version: "v1"} // Kind takes an unqualified kind and returns back a Group qualified GroupKind func Kind(kind string) schema.GroupKind { diff --git a/pkg/engine/policy/validate_test.go b/pkg/engine/policy/validate_test.go index d96244d940..ff6e5e25a0 100644 --- a/pkg/engine/policy/validate_test.go +++ b/pkg/engine/policy/validate_test.go @@ -673,7 +673,7 @@ func Test_Validate_Validate_Unsupported(t *testing.T) { func Test_Validate_Policy(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "container-security-context" @@ -978,7 +978,7 @@ func Test_Validate_Generate_HasAnchors(t *testing.T) { func Test_Validate_ErrorFormat(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "test-error-format" diff --git a/pkg/engine/validation_test.go b/pkg/engine/validation_test.go index b834b25d25..2e5bc9eeb1 100644 --- a/pkg/engine/validation_test.go +++ b/pkg/engine/validation_test.go @@ -1542,7 +1542,7 @@ func TestValidateMapElement_OneElementInArrayNotPass(t *testing.T) { func TestValidate_ServiceTest(t *testing.T) { rawPolicy := []byte(`{ - "apiVersion":"kyverno.nirmata.io/v1alpha1", + "apiVersion":"kyverno.nirmata.io/v1", "kind":"ClusterPolicy", "metadata":{ "name":"policy-service" @@ -1635,7 +1635,7 @@ func TestValidate_ServiceTest(t *testing.T) { func TestValidate_MapHasFloats(t *testing.T) { rawPolicy := []byte(`{ - "apiVersion":"kyverno.nirmata.io/v1alpha1", + "apiVersion":"kyverno.nirmata.io/v1", "kind":"ClusterPolicy", "metadata":{ "name":"policy-deployment-changed" @@ -1733,7 +1733,7 @@ func TestValidate_MapHasFloats(t *testing.T) { func TestValidate_image_tag_fail(t *testing.T) { // If image tag is latest then imagepull policy needs to be checked rawPolicy := []byte(`{ - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-image" @@ -1831,7 +1831,7 @@ func TestValidate_image_tag_fail(t *testing.T) { func TestValidate_image_tag_pass(t *testing.T) { // If image tag is latest then imagepull policy needs to be checked rawPolicy := []byte(`{ - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-image" @@ -1929,7 +1929,7 @@ func TestValidate_image_tag_pass(t *testing.T) { func TestValidate_Fail_anyPattern(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-namespace" @@ -2003,7 +2003,7 @@ func TestValidate_Fail_anyPattern(t *testing.T) { func TestValidate_host_network_port(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-host-network-port" @@ -2085,7 +2085,7 @@ func TestValidate_host_network_port(t *testing.T) { func TestValidate_anchor_arraymap_pass(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-host-path" @@ -2174,7 +2174,7 @@ func TestValidate_anchor_arraymap_pass(t *testing.T) { func TestValidate_anchor_arraymap_fail(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-host-path" @@ -2262,7 +2262,7 @@ func TestValidate_anchor_arraymap_fail(t *testing.T) { func TestValidate_anchor_map_notfound(t *testing.T) { // anchor not present in resource rawPolicy := []byte(`{ - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2331,7 +2331,7 @@ func TestValidate_anchor_map_notfound(t *testing.T) { func TestValidate_anchor_map_found_valid(t *testing.T) { // anchor not present in resource rawPolicy := []byte(`{ - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2403,7 +2403,7 @@ func TestValidate_anchor_map_found_valid(t *testing.T) { func TestValidate_anchor_map_found_invalid(t *testing.T) { // anchor not present in resource rawPolicy := []byte(`{ - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2476,7 +2476,7 @@ func TestValidate_AnchorList_pass(t *testing.T) { // anchor not present in resource rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2550,7 +2550,7 @@ func TestValidate_AnchorList_pass(t *testing.T) { func TestValidate_AnchorList_fail(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2624,7 +2624,7 @@ func TestValidate_existenceAnchor_fail(t *testing.T) { // anchor not present in resource rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2699,7 +2699,7 @@ func TestValidate_existenceAnchor_pass(t *testing.T) { // anchor not present in resource rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "policy-secaas-k8s" @@ -2772,7 +2772,7 @@ func TestValidate_existenceAnchor_pass(t *testing.T) { func TestValidate_negationAnchor_deny(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-host-path" @@ -2859,7 +2859,7 @@ func TestValidate_negationAnchor_deny(t *testing.T) { func TestValidate_negationAnchor_pass(t *testing.T) { rawPolicy := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "validate-host-path" diff --git a/pkg/policystore/policystore_test.go b/pkg/policystore/policystore_test.go index 126d7e4170..49eb39a47e 100644 --- a/pkg/policystore/policystore_test.go +++ b/pkg/policystore/policystore_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - v1alpha1 "github.com/nirmata/kyverno/pkg/api/kyverno/v1" + kyverno "github.com/nirmata/kyverno/pkg/api/kyverno/v1" "github.com/nirmata/kyverno/pkg/client/clientset/versioned/fake" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" @@ -16,7 +16,7 @@ import ( func Test_Operations(t *testing.T) { rawPolicy1 := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "test-policy1" @@ -92,7 +92,7 @@ func Test_Operations(t *testing.T) { rawPolicy2 := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "test-policy2" @@ -152,7 +152,7 @@ func Test_Operations(t *testing.T) { rawPolicy3 := []byte(` { - "apiVersion": "kyverno.io/v1alpha1", + "apiVersion": "kyverno.io/v1", "kind": "ClusterPolicy", "metadata": { "name": "test-policy3" @@ -175,18 +175,18 @@ func Test_Operations(t *testing.T) { ] } }`) - var policy1 v1alpha1.ClusterPolicy + var policy1 kyverno.ClusterPolicy json.Unmarshal(rawPolicy1, &policy1) - var policy2 v1alpha1.ClusterPolicy + var policy2 kyverno.ClusterPolicy json.Unmarshal(rawPolicy2, &policy2) - var policy3 v1alpha1.ClusterPolicy + var policy3 kyverno.ClusterPolicy json.Unmarshal(rawPolicy3, &policy3) - scheme.Scheme.AddKnownTypes(v1alpha1.SchemeGroupVersion, - &v1alpha1.ClusterPolicy{}, + scheme.Scheme.AddKnownTypes(kyverno.SchemeGroupVersion, + &kyverno.ClusterPolicy{}, ) var obj runtime.Object var err error - var retPolicies []v1alpha1.ClusterPolicy + var retPolicies []kyverno.ClusterPolicy polices := []runtime.Object{} // list of runtime objects decode := scheme.Codecs.UniversalDeserializer().Decode @@ -221,7 +221,7 @@ func Test_Operations(t *testing.T) { if err != nil { t.Error(err) } - if !reflect.DeepEqual(retPolicies, []v1alpha1.ClusterPolicy{policy1, policy2}) { + if !reflect.DeepEqual(retPolicies, []kyverno.ClusterPolicy{policy1, policy2}) { t.Error("not matching") } @@ -232,7 +232,7 @@ func Test_Operations(t *testing.T) { t.Error(err) } // Lookup - if !reflect.DeepEqual(retPolicies, []v1alpha1.ClusterPolicy{policy2}) { + if !reflect.DeepEqual(retPolicies, []kyverno.ClusterPolicy{policy2}) { t.Error("not matching") } // Add @@ -242,7 +242,7 @@ func Test_Operations(t *testing.T) { t.Error(err) } - if len(retPolicies) != len([]v1alpha1.ClusterPolicy{policy1, policy2}) { + if len(retPolicies) != len([]kyverno.ClusterPolicy{policy1, policy2}) { // checking length as the order of polcies might be different t.Error("not matching") } @@ -251,7 +251,7 @@ func Test_Operations(t *testing.T) { if err != nil { t.Error(err) } - if !reflect.DeepEqual(retPolicies, []v1alpha1.ClusterPolicy{policy3}) { + if !reflect.DeepEqual(retPolicies, []kyverno.ClusterPolicy{policy3}) { t.Error("not matching") } @@ -261,21 +261,21 @@ type FakeLister struct { client *fake.Clientset } -func (fk *FakeLister) List(selector labels.Selector) (ret []*v1alpha1.ClusterPolicy, err error) { +func (fk *FakeLister) List(selector labels.Selector) (ret []*kyverno.ClusterPolicy, err error) { return nil, nil } -func (fk *FakeLister) Get(name string) (*v1alpha1.ClusterPolicy, error) { +func (fk *FakeLister) Get(name string) (*kyverno.ClusterPolicy, error) { return fk.client.KyvernoV1().ClusterPolicies().Get(name, v1.GetOptions{}) } -func (fk *FakeLister) GetPolicyForPolicyViolation(pv *v1alpha1.ClusterPolicyViolation) ([]*v1alpha1.ClusterPolicy, error) { +func (fk *FakeLister) GetPolicyForPolicyViolation(pv *kyverno.ClusterPolicyViolation) ([]*kyverno.ClusterPolicy, error) { return nil, nil } -func (fk *FakeLister) ListResources(selector labels.Selector) (ret []*v1alpha1.ClusterPolicy, err error) { +func (fk *FakeLister) ListResources(selector labels.Selector) (ret []*kyverno.ClusterPolicy, err error) { return nil, nil } -func (fk *FakeLister) GetPolicyForNamespacedPolicyViolation(pv *v1alpha1.NamespacedPolicyViolation) ([]*v1alpha1.ClusterPolicy, error) { +func (fk *FakeLister) GetPolicyForNamespacedPolicyViolation(pv *kyverno.NamespacedPolicyViolation) ([]*kyverno.ClusterPolicy, error) { return nil, nil } diff --git a/pkg/policyviolation/generator.go b/pkg/policyviolation/generator.go index 0e7bc2ed87..483d7dad0d 100644 --- a/pkg/policyviolation/generator.go +++ b/pkg/policyviolation/generator.go @@ -10,7 +10,7 @@ import ( "github.com/golang/glog" kyverno "github.com/nirmata/kyverno/pkg/api/kyverno/v1" kyvernoclient "github.com/nirmata/kyverno/pkg/client/clientset/versioned" - kyvernov1alpha1 "github.com/nirmata/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1" + kyvernov1 "github.com/nirmata/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1" kyvernolister "github.com/nirmata/kyverno/pkg/client/listers/kyverno/v1" client "github.com/nirmata/kyverno/pkg/dclient" dclient "github.com/nirmata/kyverno/pkg/dclient" @@ -27,7 +27,7 @@ const workQueueRetryLimit = 3 //Generator creates PV type Generator struct { dclient *dclient.Client - pvInterface kyvernov1alpha1.KyvernoV1Interface + pvInterface kyvernov1.KyvernoV1Interface pvLister kyvernolister.ClusterPolicyViolationLister nspvLister kyvernolister.NamespacedPolicyViolationLister queue workqueue.RateLimitingInterface @@ -237,7 +237,7 @@ func (gen *Generator) syncHandler(info Info) error { return nil } -func createPVS(dclient *client.Client, pvs []kyverno.ClusterPolicyViolation, pvLister kyvernolister.ClusterPolicyViolationLister, pvInterface kyvernov1alpha1.KyvernoV1Interface) error { +func createPVS(dclient *client.Client, pvs []kyverno.ClusterPolicyViolation, pvLister kyvernolister.ClusterPolicyViolationLister, pvInterface kyvernov1.KyvernoV1Interface) error { for _, pv := range pvs { if err := createPVNew(dclient, pv, pvLister, pvInterface); err != nil { return err @@ -246,7 +246,7 @@ func createPVS(dclient *client.Client, pvs []kyverno.ClusterPolicyViolation, pvL return nil } -func createPVNew(dclient *client.Client, pv kyverno.ClusterPolicyViolation, pvLister kyvernolister.ClusterPolicyViolationLister, pvInterface kyvernov1alpha1.KyvernoV1Interface) error { +func createPVNew(dclient *client.Client, pv kyverno.ClusterPolicyViolation, pvLister kyvernolister.ClusterPolicyViolationLister, pvInterface kyvernov1.KyvernoV1Interface) error { var err error // PV already exists ePV, err := getExistingPVIfAny(pvLister, pv) diff --git a/pkg/policyviolation/namespacedpv.go b/pkg/policyviolation/namespacedpv.go index 5c84dcbe08..70a21b8239 100644 --- a/pkg/policyviolation/namespacedpv.go +++ b/pkg/policyviolation/namespacedpv.go @@ -6,7 +6,7 @@ import ( "github.com/golang/glog" kyverno "github.com/nirmata/kyverno/pkg/api/kyverno/v1" - kyvernov1alpha1 "github.com/nirmata/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1" + kyvernov1 "github.com/nirmata/kyverno/pkg/client/clientset/versioned/typed/kyverno/v1" kyvernolister "github.com/nirmata/kyverno/pkg/client/listers/kyverno/v1" dclient "github.com/nirmata/kyverno/pkg/dclient" labels "k8s.io/apimachinery/pkg/labels" @@ -62,7 +62,7 @@ func buildNamespacedPVWithOwner(dclient *dclient.Client, info Info) (pvs []kyver return } -func createNamespacedPV(dclient *dclient.Client, pvLister kyvernolister.NamespacedPolicyViolationLister, pvInterface kyvernov1alpha1.KyvernoV1Interface, pvs []kyverno.NamespacedPolicyViolation) error { +func createNamespacedPV(dclient *dclient.Client, pvLister kyvernolister.NamespacedPolicyViolationLister, pvInterface kyvernov1.KyvernoV1Interface, pvs []kyverno.NamespacedPolicyViolation) error { for _, newPv := range pvs { glog.V(4).Infof("creating namespaced policyViolation resource for policy %s and resource %s", newPv.Spec.Policy, newPv.Spec.ResourceSpec.ToKey()) // check if there was a previous policy voilation for policy & resource combination diff --git a/pkg/webhookconfig/policy.go b/pkg/webhookconfig/policy.go index 41fc8e81af..f9075d3ee6 100644 --- a/pkg/webhookconfig/policy.go +++ b/pkg/webhookconfig/policy.go @@ -28,7 +28,7 @@ func (wrc *WebhookRegistrationClient) contructPolicyValidatingWebhookConfig(caDa wrc.timeoutSeconds, "clusterpolicies/*", "kyverno.io", - "v1alpha1", + "v1", []admregapi.OperationType{admregapi.Create, admregapi.Update}, ), }, @@ -52,7 +52,7 @@ func (wrc *WebhookRegistrationClient) contructDebugPolicyValidatingWebhookConfig wrc.timeoutSeconds, "clusterpolicies/*", "kyverno.io", - "v1alpha1", + "v1", []admregapi.OperationType{admregapi.Create, admregapi.Update}, ), }, @@ -76,7 +76,7 @@ func (wrc *WebhookRegistrationClient) contructPolicyMutatingWebhookConfig(caData wrc.timeoutSeconds, "clusterpolicies/*", "kyverno.io", - "v1alpha1", + "v1", []admregapi.OperationType{admregapi.Create, admregapi.Update}, ), }, @@ -99,7 +99,7 @@ func (wrc *WebhookRegistrationClient) contructDebugPolicyMutatingWebhookConfig(c wrc.timeoutSeconds, "clusterpolicies/*", "kyverno.io", - "v1alpha1", + "v1", []admregapi.OperationType{admregapi.Create, admregapi.Update}, ), },