Skip to content

Commit

Permalink
set default empty string to counter qualifiers ('wasm data items') to…
Browse files Browse the repository at this point in the history
… prevent selectors that fail to select a value to invalidate the limit
  • Loading branch information
guicassolato committed Aug 22, 2023
1 parent 0adfe0c commit 0d21000
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/rlptools/wasm_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func dataFromLimt(limitIdentifier string, limit *kuadrantv1beta2.Limit) (data []
data = append(data, wasm.DataItem{Static: &wasm.StaticSpec{Key: limitIdentifier, Value: "1"}})

for _, counter := range limit.Counters {
data = append(data, wasm.DataItem{Selector: &wasm.SelectorSpec{Selector: counter}})
data = append(data, wasm.DataItem{Selector: &wasm.SelectorSpec{Selector: counter, Default: common.Ptr("")}})
}

return data
Expand Down
2 changes: 2 additions & 0 deletions pkg/rlptools/wasm_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
gatewayapiv1beta1 "sigs.k8s.io/gateway-api/apis/v1beta1"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/rlptools/wasm"
)

Expand Down Expand Up @@ -318,6 +319,7 @@ func TestWasmRules(t *testing.T) {
{
Selector: &wasm.SelectorSpec{
Selector: "auth.identity.username",
Default: common.Ptr(""),
},
},
},
Expand Down

0 comments on commit 0d21000

Please sign in to comment.