From 518af8f3798ec165fda7ef7c28b49def85c90e36 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 23 Nov 2023 08:43:01 -0500 Subject: [PATCH 1/2] Actually name Limitador's RL --- controllers/ratelimitpolicy_controller_test.go | 3 +++ pkg/rlptools/utils.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/controllers/ratelimitpolicy_controller_test.go b/controllers/ratelimitpolicy_controller_test.go index 228070dac..e7f2ec639 100644 --- a/controllers/ratelimitpolicy_controller_test.go +++ b/controllers/ratelimitpolicy_controller_test.go @@ -139,6 +139,7 @@ var _ = Describe("RateLimitPolicy controller", func() { Namespace: rlptools.LimitsNamespaceFromRLP(rlp), Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: rlptools.LimitsNameFromRLP(rlp), })) // Check wasm plugin @@ -477,6 +478,7 @@ var _ = Describe("RateLimitPolicy controller", func() { Namespace: rlptools.LimitsNamespaceFromRLP(rlp), Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: rlptools.LimitsNameFromRLP(rlp), })) // Check wasm plugin @@ -594,6 +596,7 @@ var _ = Describe("RateLimitPolicy controller", func() { Namespace: rlptools.LimitsNamespaceFromRLP(rlp), Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: rlptools.LimitsNameFromRLP(rlp), })) // Check wasm plugin diff --git a/pkg/rlptools/utils.go b/pkg/rlptools/utils.go index 95d282396..18118b19f 100644 --- a/pkg/rlptools/utils.go +++ b/pkg/rlptools/utils.go @@ -51,6 +51,7 @@ func LimitadorRateLimitsFromRLP(rlp *kuadrantv1beta2.RateLimitPolicy) []limitado Seconds: seconds, Conditions: []string{fmt.Sprintf("%s == \"1\"", limitIdentifier)}, Variables: common.GetEmptySliceIfNil(limit.CountersAsStringList()), + Name: LimitsNameFromRLP(rlp), }) } } @@ -61,6 +62,10 @@ func LimitsNamespaceFromRLP(rlp *kuadrantv1beta2.RateLimitPolicy) string { return fmt.Sprintf("%s/%s", rlp.GetNamespace(), rlp.GetName()) } +func LimitsNameFromRLP(rlp *kuadrantv1beta2.RateLimitPolicy) string { + return LimitsNamespaceFromRLP(rlp) +} + var timeUnitMap = map[kuadrantv1beta2.TimeUnit]int{ kuadrantv1beta2.TimeUnit("second"): 1, kuadrantv1beta2.TimeUnit("minute"): 60, From dc031475040353ae00c97351c82d4aaca143db9c Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Thu, 23 Nov 2023 08:58:18 -0500 Subject: [PATCH 2/2] Fix unit tests --- pkg/rlptools/utils_test.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/rlptools/utils_test.go b/pkg/rlptools/utils_test.go index 79677dba6..c20db49ee 100644 --- a/pkg/rlptools/utils_test.go +++ b/pkg/rlptools/utils_test.go @@ -193,6 +193,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 10, Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: "testNS/rlpA", }, }, }, @@ -206,6 +207,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 10, Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: "testNS/rlpA", }, { Namespace: "testNS/rlpA", @@ -213,6 +215,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 3600, Conditions: []string{`limit.l2__8a1cee43 == "1"`}, Variables: []string{}, + Name: "testNS/rlpA", }, }, }, @@ -226,6 +229,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 10, Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: "testNS/rlpA", }, { Namespace: "testNS/rlpA", @@ -233,6 +237,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 60, Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{}, + Name: "testNS/rlpA", }, }, }, @@ -246,6 +251,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) { Seconds: 10, Conditions: []string{`limit.l1__2804bad6 == "1"`}, Variables: []string{"request.path"}, + Name: "testNS/rlpA", }, }, },