From 7e876a96eab93c2768161ca5d6b8ff8fdd98df2c Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Tue, 7 Nov 2023 13:45:59 -0500 Subject: [PATCH] Add support for name in limit definitions --- api/v1alpha1/limitador_types.go | 1 + bundle/manifests/limitador-operator.clusterserviceversion.yaml | 3 ++- bundle/manifests/limitador.kuadrant.io_limitadors.yaml | 2 ++ config/crd/bases/limitador.kuadrant.io_limitadors.yaml | 2 ++ config/samples/limitador_v1alpha1_limitador.yaml | 1 + controllers/limitador_controller_test.go | 1 + pkg/limitador/k8s_objects_test.go | 1 + 7 files changed, 10 insertions(+), 1 deletion(-) diff --git a/api/v1alpha1/limitador_types.go b/api/v1alpha1/limitador_types.go index d44bc6a4..f7312b42 100644 --- a/api/v1alpha1/limitador_types.go +++ b/api/v1alpha1/limitador_types.go @@ -252,6 +252,7 @@ type RateLimit struct { Namespace string `json:"namespace"` Seconds int `json:"seconds"` Variables []string `json:"variables"` + Name string `json:"name,omitempty"` } // LimitadorStatus defines the observed state of Limitador diff --git a/bundle/manifests/limitador-operator.clusterserviceversion.yaml b/bundle/manifests/limitador-operator.clusterserviceversion.yaml index b062883e..c75cbc3f 100644 --- a/bundle/manifests/limitador-operator.clusterserviceversion.yaml +++ b/bundle/manifests/limitador-operator.clusterserviceversion.yaml @@ -17,6 +17,7 @@ metadata: "get_toy == 'yes'" ], "max_value": 2, + "name": "toy_get_route", "namespace": "toystore-app", "seconds": 30, "variables": [] @@ -36,7 +37,7 @@ metadata: capabilities: Basic Install categories: Integration & Delivery containerImage: quay.io/kuadrant/limitador-operator:latest - createdAt: "2023-09-27T14:09:01Z" + createdAt: "2023-11-08T14:01:55Z" operators.operatorframework.io/builder: operator-sdk-v1.28.1 operators.operatorframework.io/project_layout: go.kubebuilder.io/v3 repository: https://github.com/Kuadrant/limitador-operator diff --git a/bundle/manifests/limitador.kuadrant.io_limitadors.yaml b/bundle/manifests/limitador.kuadrant.io_limitadors.yaml index 2a3eb0dd..d1773e41 100644 --- a/bundle/manifests/limitador.kuadrant.io_limitadors.yaml +++ b/bundle/manifests/limitador.kuadrant.io_limitadors.yaml @@ -872,6 +872,8 @@ spec: type: array max_value: type: integer + name: + type: string namespace: type: string seconds: diff --git a/config/crd/bases/limitador.kuadrant.io_limitadors.yaml b/config/crd/bases/limitador.kuadrant.io_limitadors.yaml index ca7585c2..703e5bed 100644 --- a/config/crd/bases/limitador.kuadrant.io_limitadors.yaml +++ b/config/crd/bases/limitador.kuadrant.io_limitadors.yaml @@ -873,6 +873,8 @@ spec: type: array max_value: type: integer + name: + type: string namespace: type: string seconds: diff --git a/config/samples/limitador_v1alpha1_limitador.yaml b/config/samples/limitador_v1alpha1_limitador.yaml index 2d98ef2d..5475cb2d 100644 --- a/config/samples/limitador_v1alpha1_limitador.yaml +++ b/config/samples/limitador_v1alpha1_limitador.yaml @@ -14,3 +14,4 @@ spec: namespace: toystore-app seconds: 30 variables: [] + name: "toy_get_route" diff --git a/controllers/limitador_controller_test.go b/controllers/limitador_controller_test.go index d00dc30d..4d731ffe 100644 --- a/controllers/limitador_controller_test.go +++ b/controllers/limitador_controller_test.go @@ -82,6 +82,7 @@ var _ = Describe("Limitador controller", func() { Namespace: "test-namespace", Seconds: 60, Variables: []string{"user_id"}, + Name: "useless", }, { Conditions: []string{"req.method == 'POST'"}, diff --git a/pkg/limitador/k8s_objects_test.go b/pkg/limitador/k8s_objects_test.go index 15fcb7b8..61fec6ce 100644 --- a/pkg/limitador/k8s_objects_test.go +++ b/pkg/limitador/k8s_objects_test.go @@ -254,6 +254,7 @@ func TestLimitsConfigMap(t *testing.T) { MaxValue: 1000, Namespace: "my-ns", Seconds: 60, + Name: "useless", }, { Conditions: []string{"cond == '1'"},