Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actually name Limitador's RL #334

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions controllers/ratelimitpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions pkg/rlptools/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})
}
}
Expand All @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions pkg/rlptools/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) {
Seconds: 10,
Conditions: []string{`limit.l1__2804bad6 == "1"`},
Variables: []string{},
Name: "testNS/rlpA",
},
},
},
Expand All @@ -206,13 +207,15 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) {
Seconds: 10,
Conditions: []string{`limit.l1__2804bad6 == "1"`},
Variables: []string{},
Name: "testNS/rlpA",
},
{
Namespace: "testNS/rlpA",
MaxValue: 3,
Seconds: 3600,
Conditions: []string{`limit.l2__8a1cee43 == "1"`},
Variables: []string{},
Name: "testNS/rlpA",
},
},
},
Expand All @@ -226,13 +229,15 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) {
Seconds: 10,
Conditions: []string{`limit.l1__2804bad6 == "1"`},
Variables: []string{},
Name: "testNS/rlpA",
},
{
Namespace: "testNS/rlpA",
MaxValue: 3,
Seconds: 60,
Conditions: []string{`limit.l1__2804bad6 == "1"`},
Variables: []string{},
Name: "testNS/rlpA",
},
},
},
Expand All @@ -246,6 +251,7 @@ func TestLimitadorRateLimitsFromRLP(t *testing.T) {
Seconds: 10,
Conditions: []string{`limit.l1__2804bad6 == "1"`},
Variables: []string{"request.path"},
Name: "testNS/rlpA",
},
},
},
Expand Down
Loading