Skip to content

Commit

Permalink
wasmplugin rules sorted by limit name
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Apr 3, 2024
1 parent c3a561b commit a46f05f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pkg/rlptools/wasm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"reflect"
"slices"
"strings"

_struct "google.golang.org/protobuf/types/known/structpb"
Expand All @@ -30,7 +31,16 @@ func WasmRules(rlp *kuadrantv1beta2.RateLimitPolicy, route *gatewayapiv1.HTTPRou
return rules
}

for limitName := range rlp.Spec.Limits {
// Sort RLP limits for consistent comparison with existing wasmplugin objects
limitNames := make([]string, 0, len(rlp.Spec.Limits))
for name := range rlp.Spec.Limits {
limitNames = append(limitNames, name)
}

// sort the slice by limit name
slices.Sort(limitNames)

for _, limitName := range limitNames {
// 1 RLP limit <---> 1 WASM rule
limit := rlp.Spec.Limits[limitName]
limitIdentifier := LimitNameToLimitadorIdentifier(limitName)
Expand Down

0 comments on commit a46f05f

Please sign in to comment.