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, 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", }, }, },