nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: fxamacker/cbor
Pull request #630 (2025-02-23 22:38:24)

Add missing copyright notice to a few files
Several files were missing copyright notice. This PR updates them to add copyright notice:
- [x] simplevalue.go
- [x] tag.go
- [x] tag_test.go



Patch:
diff --git a/simplevalue.go b/simplevalue.go
index de175ce..db1e03a 100644
--- a/simplevalue.go
+++ b/simplevalue.go
@@ -1,3 +1,6 @@
+// Copyright (c) Faye Amacker. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
 package cbor
 
 import (
diff --git a/tag.go b/tag.go
index ecd1136..7e62245 100644
--- a/tag.go
+++ b/tag.go
@@ -1,3 +1,6 @@
+// Copyright (c) Faye Amacker. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
 package cbor
 
 import (


Test patch:
diff --git a/json_test.go b/json_test.go
index ab6d5c3..67352ec 100644
--- a/json_test.go
+++ b/json_test.go
@@ -1,3 +1,6 @@
+// Copyright (c) Faye Amacker. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
 package cbor_test
 
 import (
diff --git a/tag_test.go b/tag_test.go
index de7e467..74d46eb 100644
--- a/tag_test.go
+++ b/tag_test.go
@@ -1,3 +1,6 @@
+// Copyright (c) Faye Amacker. All rights reserved.
+// Licensed under the MIT License. See LICENSE in the project root for license information.
+
 package cbor
 
 import (
Repository: doitintl/kube-no-trouble
Pull request #159 (2021-06-10 19:05:24)

feat: Cover deprecated `scheduling.k8s.io/v1beta1` - PriorityClass resource
Cover deprecated `scheduling.k8s.io/v1beta1` - PriorityClass resource

As per https://kubernetes.io/docs/reference/using-api/deprecation-guide/ add PriorityClass resource.

Review after #156, it will be easier :)
Part of #135


Patch:
diff --git a/fixtures/priorityclass-v1beta1.yaml b/fixtures/priorityclass-v1beta1.yaml
new file mode 100644
index 0000000..83040be
--- /dev/null
+++ b/fixtures/priorityclass-v1beta1.yaml
@@ -0,0 +1,8 @@
+---
+apiVersion: scheduling.k8s.io/v1beta1
+kind: PriorityClass
+metadata:
+  name: default
+value: 100
+globalDefault: true
+description: "Default priority class"
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index ae4a010..e0f94a8 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -82,6 +82,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "csinodes"},
 		schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "storageclasses"},
 		schema.GroupVersionResource{Group: "storage.k8s.io", Version: "v1", Resource: "volumeattachments"},
+		schema.GroupVersionResource{Group: "scheduling.k8s.io/v1", Version: "v1", Resource: "priorityclasses"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-22.rego b/pkg/rules/rego/deprecated-1-22.rego
index c8beaed..1abaef2 100644
--- a/pkg/rules/rego/deprecated-1-22.rego
+++ b/pkg/rules/rego/deprecated-1-22.rego
@@ -46,6 +46,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "coordination.k8s.io/v1",
 			"since": "1.19",
 		},
+		"PriorityClass": {
+			"old": ["scheduling.k8s.io/v1beta1"],
+			"new": "scheduling.k8s.io/v1",
+			"since": "1.14",
+		},
 		"CSIDriver": {
 			"old": ["storage.k8s.io/v1beta1"],
 			"new": "storage.k8s.io/v1",


Test patch:
diff --git a/test/rules_122_test.go b/test/rules_122_test.go
index 1be7c03..96f27f8 100644
--- a/test/rules_122_test.go
+++ b/test/rules_122_test.go
@@ -16,6 +16,7 @@ func TestRego116(t *testing.T) {
 		{"CSINode", []string{"../fixtures/csinode-v1beta1.yaml"}, []string{"CSINode"}},
 		{"StorageClass", []string{"../fixtures/storageclass-v1beta1.yaml"}, []string{"StorageClass"}},
 		{"VolumeAttachment", []string{"../fixtures/volumeattachment-v1beta1.yaml"}, []string{"VolumeAttachment"}},
+		{"PriorityClass", []string{"../fixtures/priorityclass-v1beta1.yaml"}, []string{"PriorityClass"}},
 	}
 
 	for _, tc := range testCases {
Repository: doitintl/kube-no-trouble
Pull request #164 (2021-06-11 13:04:53)

fix: Remove `LeaseList` and add `Lease` to cluster collector, add test for `Lease`
This PR is about minor fixes and adding test for `coordination.k8s.io/v1beta1` API group.

Changes:
- fix: Add Leases to be pulled by cluster collector
- fix: Remove LeaseList from rules
- test: Add test for Lease

#135, #113 


Patch:
diff --git a/fixtures/lease-v1beta1.yaml b/fixtures/lease-v1beta1.yaml
new file mode 100644
index 0000000..f00e6f4
--- /dev/null
+++ b/fixtures/lease-v1beta1.yaml
@@ -0,0 +1,9 @@
+apiVersion: coordination.k8s.io/v1beta1
+kind: Lease
+metadata:
+  name: example
+  namespace: default
+spec:
+  holderIdentity: "12"
+  leaseDurationSeconds: 60
+  leaseTransitions: 123
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index 3e1bf8d..d0ce93b 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -88,6 +88,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "clusterrolebindings"},
 		schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "roles"},
 		schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "rolebindings"},
+		schema.GroupVersionResource{Group: "coordination.k8s.io", Version: "v1", Resource: "leases"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-22.rego b/pkg/rules/rego/deprecated-1-22.rego
index fe9c041..9ce84fd 100644
--- a/pkg/rules/rego/deprecated-1-22.rego
+++ b/pkg/rules/rego/deprecated-1-22.rego
@@ -44,12 +44,7 @@ deprecated_api(kind, api_version) = api {
 		"Lease": {
 			"old": ["coordination.k8s.io/v1beta1"],
 			"new": "coordination.k8s.io/v1",
-			"since": "1.19",
-		},
-		"LeaseList": {
-			"old": ["coordination.k8s.io/v1beta1"],
-			"new": "coordination.k8s.io/v1",
-			"since": "1.19",
+			"since": "1.14",
 		},
 		"PriorityClass": {
 			"old": ["scheduling.k8s.io/v1beta1"],


Test patch:
diff --git a/test/rules_122_test.go b/test/rules_122_test.go
index 59bc2bb..eaa12a4 100644
--- a/test/rules_122_test.go
+++ b/test/rules_122_test.go
@@ -23,6 +23,7 @@ func TestRego122(t *testing.T) {
 		{"PriorityClass", []string{"../fixtures/priorityclass-v1beta1.yaml"}, []string{"PriorityClass"}},
 		{"Ingress", []string{"../fixtures/ingress-v1beta1.yaml"}, []string{"Ingress"}},
 		{"IngressClass", []string{"../fixtures/ingressclass-v1beta1.yaml"}, []string{"IngressClass"}},
+		{"Lease", []string{"../fixtures/lease-v1beta1.yaml"}, []string{"Lease"}},
 	}
 
 	for _, tc := range testCases {
Repository: doitintl/kube-no-trouble
Pull request #165 (2021-06-11 13:24:09)

feat: Cover deprecated `certificates.k8s.io/v1beta1` API group
This PR adds coverage of deprecated certificates.k8s.io/v1beta1 API group

As per https://kubernetes.io/docs/reference/using-api/deprecation-guide/,
add `certificates.k8s.io/v1beta1` group of resources.

Part of #135


Patch:
diff --git a/fixtures/certificatesigningrequest-v1beta1.yaml b/fixtures/certificatesigningrequest-v1beta1.yaml
new file mode 100644
index 0000000..f646ffd
--- /dev/null
+++ b/fixtures/certificatesigningrequest-v1beta1.yaml
@@ -0,0 +1,9 @@
+apiVersion: certificates.k8s.io/v1beta1
+kind: CertificateSigningRequest
+metadata:
+  name: example.com
+spec:
+  request: aGVsbG9YWAo=
+  usages:
+  - key encipherment
+  - server auth
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index d0ce93b..0601c87 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -89,6 +89,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "roles"},
 		schema.GroupVersionResource{Group: "rbac.authorization.k8s.io", Version: "v1", Resource: "rolebindings"},
 		schema.GroupVersionResource{Group: "coordination.k8s.io", Version: "v1", Resource: "leases"},
+		schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1beta1", Resource: "certificatesigningrequests"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-22.rego b/pkg/rules/rego/deprecated-1-22.rego
index 9ce84fd..aaacee6 100644
--- a/pkg/rules/rego/deprecated-1-22.rego
+++ b/pkg/rules/rego/deprecated-1-22.rego
@@ -91,6 +91,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "rbac.authorization.k8s.io/v1",
 			"since": "1.8",
 		},
+		"CertificateSigningRequest": {
+			"old": ["certificates.k8s.io/v1beta1"],
+			"new": "certificates.k8s.io/v1",
+			"since": "1.19",
+		},
 	}
 
 	deprecated_apis[kind].old[_] == api_version


Test patch:
diff --git a/test/rules_122_test.go b/test/rules_122_test.go
index eaa12a4..dc43102 100644
--- a/test/rules_122_test.go
+++ b/test/rules_122_test.go
@@ -24,6 +24,7 @@ func TestRego122(t *testing.T) {
 		{"Ingress", []string{"../fixtures/ingress-v1beta1.yaml"}, []string{"Ingress"}},
 		{"IngressClass", []string{"../fixtures/ingressclass-v1beta1.yaml"}, []string{"IngressClass"}},
 		{"Lease", []string{"../fixtures/lease-v1beta1.yaml"}, []string{"Lease"}},
+		{"CertificateSigningRequest", []string{"../fixtures/certificatesigningrequest-v1beta1.yaml"}, []string{"CertificateSigningRequest"}},
 	}
 
 	for _, tc := range testCases {
Repository: doitintl/kube-no-trouble
Pull request #168 (2021-06-11 17:13:57)

feat: Cover deprecated `apiregistration.k8s.io/v1beta1` API group
This PR adds coverage of deprecated `apiregistration.k8s.io/v1beta1` API group - `APIService` resource.

Part of #135


Patch:
diff --git a/fixtures/apiservice-v1beta1.yaml b/fixtures/apiservice-v1beta1.yaml
new file mode 100644
index 0000000..1a5f359
--- /dev/null
+++ b/fixtures/apiservice-v1beta1.yaml
@@ -0,0 +1,13 @@
+apiVersion: apiregistration.k8s.io/v1beta1
+kind: APIService
+metadata:
+  name: v1alpha1.wardle.example.com
+spec:
+  insecureSkipTLSVerify: true
+  group: wardle.example.com
+  groupPriorityMinimum: 1000
+  versionPriority: 15
+  service:
+    name: api
+    namespace: wardle
+  version: v1alpha1
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index 0158d9a..e4921a6 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -94,6 +94,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "authorization.k8s.io", Version: "v1", Resource: "localsubjectaccessreviews"},
 		schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1", Resource: "tokenreviews"},
 		schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1", Resource: "certificatesigningrequests"},
+		schema.GroupVersionResource{Group: "apiregistration.k8s.io", Version: "v1", Resource: "apiservices"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-22.rego b/pkg/rules/rego/deprecated-1-22.rego
index 89abf6a..69f73ec 100644
--- a/pkg/rules/rego/deprecated-1-22.rego
+++ b/pkg/rules/rego/deprecated-1-22.rego
@@ -106,6 +106,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "certificates.k8s.io/v1",
 			"since": "1.19",
 		},
+		"APIService": {
+			"old": ["apiregistration.k8s.io/v1beta1"],
+			"new": "apiregistration.k8s.io/v1",
+			"since": "1.10",
+		},
 	}
 
 	deprecated_apis[kind].old[_] == api_version


Test patch:
diff --git a/test/rules_122_test.go b/test/rules_122_test.go
index c714c91..de570f8 100644
--- a/test/rules_122_test.go
+++ b/test/rules_122_test.go
@@ -29,6 +29,7 @@ func TestRego122(t *testing.T) {
 		{"SelfSubjectAccessReview", []string{"../fixtures/selfsubjectaccessreview-v1beta1.yaml"}, []string{"SelfSubjectAccessReview"}},
 		{"LocalSubjectAccessReview", []string{"../fixtures/localsubjectaccessreview-v1beta1.yaml"}, []string{"LocalSubjectAccessReview"}},
 		{"TokenReview", []string{"../fixtures/tokenreview-v1beta1.yaml"}, []string{"TokenReview"}},
+		{"APIService", []string{"../fixtures/apiservice-v1beta1.yaml"}, []string{"APIService"}},
 	}
 
 	for _, tc := range testCases {
Repository: doitintl/kube-no-trouble
Pull request #169 (2021-06-11 17:34:13)

feat: Cover deprecated `apiextensions.k8s.io/v1beta1` API group
This PR adds coverage for deprecated `apiextensions.k8s.io/v1beta1` API group - `CustomResourceDefinition` resource.

Part of #135


Patch:
diff --git a/fixtures/customresourcedefinition-v1beta1.yaml b/fixtures/customresourcedefinition-v1beta1.yaml
new file mode 100644
index 0000000..a3ef42d
--- /dev/null
+++ b/fixtures/customresourcedefinition-v1beta1.yaml
@@ -0,0 +1,20 @@
+apiVersion: apiextensions.k8s.io/v1beta1
+kind: CustomResourceDefinition
+metadata:
+        name: certificates.test.k8s.io
+spec:
+  group: test.k8s.io
+  version: v1beta1
+  scope: Cluster
+  names:
+    plural: certificates
+    singular: certificate
+    kind: Certificate
+    categories:
+      - all
+  additionalPrinterColumns:
+    - name: Status
+      type: string
+      JSONPath: .status.lastConditionState
+  subresources:
+    status: {}
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index e4921a6..6ea636b 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -95,6 +95,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "authentication.k8s.io", Version: "v1", Resource: "tokenreviews"},
 		schema.GroupVersionResource{Group: "certificates.k8s.io", Version: "v1", Resource: "certificatesigningrequests"},
 		schema.GroupVersionResource{Group: "apiregistration.k8s.io", Version: "v1", Resource: "apiservices"},
+		schema.GroupVersionResource{Group: "apiextensions.k8s.io", Version: "v1", Resource: "customresourcedefinitions"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-22.rego b/pkg/rules/rego/deprecated-1-22.rego
index 69f73ec..f41e8a3 100644
--- a/pkg/rules/rego/deprecated-1-22.rego
+++ b/pkg/rules/rego/deprecated-1-22.rego
@@ -111,6 +111,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "apiregistration.k8s.io/v1",
 			"since": "1.10",
 		},
+		"CustomResourceDefinition": {
+			"old": ["apiextensions.k8s.io/v1beta1"],
+			"new": "apiextensions.k8s.io/v1",
+			"since": "1.16",
+		},
 	}
 
 	deprecated_apis[kind].old[_] == api_version


Test patch:
diff --git a/test/rules_122_test.go b/test/rules_122_test.go
index de570f8..825667a 100644
--- a/test/rules_122_test.go
+++ b/test/rules_122_test.go
@@ -30,6 +30,7 @@ func TestRego122(t *testing.T) {
 		{"LocalSubjectAccessReview", []string{"../fixtures/localsubjectaccessreview-v1beta1.yaml"}, []string{"LocalSubjectAccessReview"}},
 		{"TokenReview", []string{"../fixtures/tokenreview-v1beta1.yaml"}, []string{"TokenReview"}},
 		{"APIService", []string{"../fixtures/apiservice-v1beta1.yaml"}, []string{"APIService"}},
+		{"CustomResourceDefinition", []string{"../fixtures/customresourcedefinition-v1beta1.yaml"}, []string{"CustomResourceDefinition"}},
 	}
 
 	for _, tc := range testCases {
Repository: doitintl/kube-no-trouble
Pull request #172 (2021-06-16 09:14:36)

feat: Cover deprecated `policy/v1beta1` API group - PodDisruptionBudget
Cover deprecated policy/v1beta1 API group - PDB

As per https://kubernetes.io/docs/reference/using-api/deprecation-guide/
add `policy/v1beta1` group - `PodDisruptionBudget` resource.

Part of #135
Easier to review after #171 


Patch:
diff --git a/fixtures/poddisruptionbudget-v1beta1.yaml b/fixtures/poddisruptionbudget-v1beta1.yaml
new file mode 100644
index 0000000..cdb4e67
--- /dev/null
+++ b/fixtures/poddisruptionbudget-v1beta1.yaml
@@ -0,0 +1,9 @@
+apiVersion: policy/v1beta1
+kind: PodDisruptionBudget
+metadata:
+  name: xy-pdb
+spec:
+  minAvailable: 2
+  selector:
+    matchLabels:
+      app: xy
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index d8e633e..1d62920 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -99,6 +99,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "mutatingwebhookconfigurations"},
 		schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "validatingwebhookconfigurations"},
 		schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1", Resource: "runtimeclasses"},
+		schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-25.rego b/pkg/rules/rego/deprecated-1-25.rego
index c67adcd..b370ab9 100644
--- a/pkg/rules/rego/deprecated-1-25.rego
+++ b/pkg/rules/rego/deprecated-1-25.rego
@@ -20,11 +20,18 @@ deprecated_resource(r) = api {
 }
 
 deprecated_api(kind, api_version) = api {
-	deprecated_apis = {"RuntimeClass": {
-		"old": ["node.k8s.io/v1beta1"],
-		"new": "node.k8s.io/v1",
-		"since": "1.20",
-	}}
+	deprecated_apis = {
+		"RuntimeClass": {
+			"old": ["node.k8s.io/v1beta1"],
+			"new": "node.k8s.io/v1",
+			"since": "1.20",
+		},
+		"PodDisruptionBudget": {
+			"old": ["policy/v1beta1"],
+			"new": "policy/v1",
+			"since": "1.21",
+		},
+	}
 
 	deprecated_apis[kind].old[_] == api_version
 


Test patch:
diff --git a/test/rules_125_test.go b/test/rules_125_test.go
index 31944e4..5a19695 100644
--- a/test/rules_125_test.go
+++ b/test/rules_125_test.go
@@ -7,6 +7,7 @@ import (
 func TestRego125(t *testing.T) {
 	testCases := []resourceFixtureTestCase{
 		{"RuntimeClass", []string{"../fixtures/runtimeclass-v1beta1.yaml"}, []string{"RuntimeClass"}},
+		{"PodDisruptionBudget", []string{"../fixtures/poddisruptionbudget-v1beta1.yaml"}, []string{"PodDisruptionBudget"}},
 	}
 
 	testReourcesUsingFixtures(t, testCases)
Repository: doitintl/kube-no-trouble
Pull request #173 (2021-06-16 09:30:53)

feat: Cover removed `policy/v1beta1` API group - PodSecurityPolicy
This PR adds coverage of removed `policy/v1beta1` API group - `PodSecurityPolicy` resource.

As per https://kubernetes.io/docs/reference/using-api/deprecation-guide/
add `policy/v1beta1z group - zPodSecurityPolicy` resource.

Part of #135
Easier to review after #172 


Patch:
diff --git a/fixtures/podsecuritypolicy-v1beta1.yaml b/fixtures/podsecuritypolicy-v1beta1.yaml
new file mode 100644
index 0000000..d7245f1
--- /dev/null
+++ b/fixtures/podsecuritypolicy-v1beta1.yaml
@@ -0,0 +1,14 @@
+apiVersion: policy/v1beta1
+kind: PodSecurityPolicy
+metadata:
+  name: example
+spec:
+  privileged: false
+  seLinux:
+    rule: RunAsAny
+  runAsUser:
+    rule: RunAsAny
+  fsGroup:
+    rule: RunAsAny
+  volumes:
+  - '*'
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index 1d62920..1557cc2 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -100,6 +100,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "admissionregistration.k8s.io", Version: "v1", Resource: "validatingwebhookconfigurations"},
 		schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1", Resource: "runtimeclasses"},
 		schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"},
+		schema.GroupVersionResource{Group: "policy", Version: "v1beta1", Resource: "podsecuritypolicies"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-25.rego b/pkg/rules/rego/deprecated-1-25.rego
index b370ab9..9099fa7 100644
--- a/pkg/rules/rego/deprecated-1-25.rego
+++ b/pkg/rules/rego/deprecated-1-25.rego
@@ -31,6 +31,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "policy/v1",
 			"since": "1.21",
 		},
+		"PodSecurityPolicy": {
+			"old": ["policy/v1beta1"],
+			"new": "<removed>",
+			"since": "1.21",
+		},
 	}
 
 	deprecated_apis[kind].old[_] == api_version


Test patch:
diff --git a/test/rules_125_test.go b/test/rules_125_test.go
index 5a19695..2b5adc6 100644
--- a/test/rules_125_test.go
+++ b/test/rules_125_test.go
@@ -8,6 +8,7 @@ func TestRego125(t *testing.T) {
 	testCases := []resourceFixtureTestCase{
 		{"RuntimeClass", []string{"../fixtures/runtimeclass-v1beta1.yaml"}, []string{"RuntimeClass"}},
 		{"PodDisruptionBudget", []string{"../fixtures/poddisruptionbudget-v1beta1.yaml"}, []string{"PodDisruptionBudget"}},
+		{"PodSecurityPolicy", []string{"../fixtures/podsecuritypolicy-v1beta1.yaml"}, []string{"PodSecurityPolicy"}},
 	}
 
 	testReourcesUsingFixtures(t, testCases)
Repository: doitintl/kube-no-trouble
Pull request #174 (2021-06-16 10:16:54)

feat: Cover deprecated `discovery.k8s.io/v1beta1` API group - EndpointSlice
This PR adds coverage of deprecated `discovery.k8s.io/v1beta1` API group - `EndpointSlice` resource.

As per https://kubernetes.io/docs/reference/using-api/deprecation-guide/
add `discovery.k8s.io/v1beta1` group - `EndpointSlice` resource.

Part of #135
Easier to review after #171 


Patch:
diff --git a/fixtures/endpointslice-v1beta1.yaml b/fixtures/endpointslice-v1beta1.yaml
new file mode 100644
index 0000000..2bce35f
--- /dev/null
+++ b/fixtures/endpointslice-v1beta1.yaml
@@ -0,0 +1,20 @@
+apiVersion: discovery.k8s.io/v1beta1
+kind: EndpointSlice
+metadata:
+  name: example-abc
+  labels:
+    kubernetes.io/service-name: example
+addressType: IPv4
+ports:
+  - name: http
+    protocol: TCP
+    port: 80
+endpoints:
+  - addresses:
+      - "10.1.2.3"
+    conditions:
+      ready: true
+    hostname: pod-1
+    topology:
+      kubernetes.io/hostname: node-1
+      topology.kubernetes.io/zone: us-west2-a
diff --git a/pkg/collector/cluster.go b/pkg/collector/cluster.go
index 1557cc2..6577b9d 100644
--- a/pkg/collector/cluster.go
+++ b/pkg/collector/cluster.go
@@ -101,6 +101,7 @@ func (c *ClusterCollector) Get() ([]map[string]interface{}, error) {
 		schema.GroupVersionResource{Group: "node.k8s.io", Version: "v1", Resource: "runtimeclasses"},
 		schema.GroupVersionResource{Group: "policy", Version: "v1", Resource: "poddisruptionbudgets"},
 		schema.GroupVersionResource{Group: "policy", Version: "v1beta1", Resource: "podsecuritypolicies"},
+		schema.GroupVersionResource{Group: "discovery.k8s.io", Version: "v1", Resource: "endpointslices"},
 	}
 	gvrs = append(gvrs, c.additionalResources...)
 
diff --git a/pkg/rules/rego/deprecated-1-25.rego b/pkg/rules/rego/deprecated-1-25.rego
index 9099fa7..e866c2b 100644
--- a/pkg/rules/rego/deprecated-1-25.rego
+++ b/pkg/rules/rego/deprecated-1-25.rego
@@ -36,6 +36,11 @@ deprecated_api(kind, api_version) = api {
 			"new": "<removed>",
 			"since": "1.21",
 		},
+		"EndpointSlice": {
+			"old": ["discovery.k8s.io/v1beta1"],
+			"new": "discovery.k8s.io/v1",
+			"since": "1.21",
+		},
 	}
 
 	deprecated_apis[kind].old[_] == api_version


Test patch:
diff --git a/test/rules_125_test.go b/test/rules_125_test.go
index 2b5adc6..47278e3 100644
--- a/test/rules_125_test.go
+++ b/test/rules_125_test.go
@@ -9,6 +9,7 @@ func TestRego125(t *testing.T) {
 		{"RuntimeClass", []string{"../fixtures/runtimeclass-v1beta1.yaml"}, []string{"RuntimeClass"}},
 		{"PodDisruptionBudget", []string{"../fixtures/poddisruptionbudget-v1beta1.yaml"}, []string{"PodDisruptionBudget"}},
 		{"PodSecurityPolicy", []string{"../fixtures/podsecuritypolicy-v1beta1.yaml"}, []string{"PodSecurityPolicy"}},
+		{"EndpointSlice", []string{"../fixtures/endpointslice-v1beta1.yaml"}, []string{"EndpointSlice"}},
 	}
 
 	testReourcesUsingFixtures(t, testCases)