Skip to content

Commit

Permalink
more descriptive wasm actionset names
Browse files Browse the repository at this point in the history
Signed-off-by: Guilherme Cassolato <[email protected]>
  • Loading branch information
guicassolato committed Oct 17, 2024
1 parent 5f1109a commit 1d18a33
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 49 deletions.
9 changes: 4 additions & 5 deletions api/v1/merge_strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ limitations under the License.
package v1

import (
"crypto/sha256"
"encoding/hex"
"sort"
"strings"

"github.com/samber/lo"
"k8s.io/apimachinery/pkg/runtime"
k8stypes "k8s.io/apimachinery/pkg/types"

"github.com/kuadrant/policy-machinery/controller"
"github.com/kuadrant/policy-machinery/machinery"
Expand Down Expand Up @@ -196,7 +195,7 @@ func PoliciesInPath(path []machinery.Targetable, predicate func(machinery.Policy
}

func PathID(path []machinery.Targetable) string {
s := strings.Join(lo.Map(path, machinery.MapTargetableToLocatorFunc), ">")
hash := sha256.Sum256([]byte(s))
return hex.EncodeToString(hash[:8])
return strings.Join(lo.Map(path, func(t machinery.Targetable, _ int) string {
return strings.TrimPrefix(k8stypes.NamespacedName{Namespace: t.GetNamespace(), Name: t.GetName()}.String(), string(k8stypes.Separator))
}), "|")

Check warning on line 200 in api/v1/merge_strategies.go

View check run for this annotation

Codecov / codecov/patch

api/v1/merge_strategies.go#L197-L200

Added lines #L197 - L200 were not covered by tests
}
8 changes: 6 additions & 2 deletions pkg/wasm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ func BuildActionSetsForPath(pathID string, path []machinery.Targetable, policyRu
return action, true

Check warning on line 59 in pkg/wasm/utils.go

View check run for this annotation

Codecov / codecov/patch

pkg/wasm/utils.go#L59

Added line #L59 was not covered by tests
})

return lo.FlatMap(kuadrantgatewayapi.HostnamesFromListenerAndHTTPRoute(listener.Listener, httpRoute.HTTPRoute), func(hostname gatewayapiv1.Hostname, i int) []kuadrantgatewayapi.HTTPRouteMatchConfig {
return lo.FlatMap(kuadrantgatewayapi.HostnamesFromListenerAndHTTPRoute(listener.Listener, httpRoute.HTTPRoute), func(hostname gatewayapiv1.Hostname, _ int) []kuadrantgatewayapi.HTTPRouteMatchConfig {
return lo.Map(httpRouteRule.Matches, func(httpRouteMatch gatewayapiv1.HTTPRouteMatch, j int) kuadrantgatewayapi.HTTPRouteMatchConfig {
actionSet := ActionSet{
Name: fmt.Sprintf("%d-%s-%d", i, pathID, j),
Name: ActionSetNameForPath(pathID, j+1, string(hostname)),
Actions: actions,

Check warning on line 66 in pkg/wasm/utils.go

View check run for this annotation

Codecov / codecov/patch

pkg/wasm/utils.go#L62-L66

Added lines #L62 - L66 were not covered by tests
}
routeRuleConditions := RouteRuleConditions{
Expand All @@ -84,6 +84,10 @@ func BuildActionSetsForPath(pathID string, path []machinery.Targetable, policyRu
}), err
}

func ActionSetNameForPath(pathID string, httpRouteMatchIndex int, hostname string) string {
return fmt.Sprintf("%s|%d|%s", pathID, httpRouteMatchIndex+1, string(hostname))

Check failure on line 88 in pkg/wasm/utils.go

View workflow job for this annotation

GitHub Actions / Lint

unnecessary conversion (unconvert)

Check warning on line 88 in pkg/wasm/utils.go

View check run for this annotation

Codecov / codecov/patch

pkg/wasm/utils.go#L87-L88

Added lines #L87 - L88 were not covered by tests
}

func ConfigFromStruct(structure *_struct.Struct) (*Config, error) {
if structure == nil {
return nil, errors.New("cannot desestructure config from nil")

Check warning on line 93 in pkg/wasm/utils.go

View check run for this annotation

Codecov / codecov/patch

pkg/wasm/utils.go#L91-L93

Added lines #L91 - L93 were not covered by tests
Expand Down
8 changes: 4 additions & 4 deletions tests/envoygateway/extension_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ var _ = Describe("wasm controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &gwRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &gwRoute.Spec.Rules[0], Name: "rule-1"},
})
actionSetName = fmt.Sprintf("%d-%s-%d", 0, pathID, 0) // Hostname: 0, HTTPRouteMatch: 0
actionSetName = wasm.ActionSetNameForPath(pathID, 1, string(gwRoute.Spec.Hostnames[0]))

gwPolicy = policyFactory(func(policy *kuadrantv1beta3.RateLimitPolicy) {
policy.Name = "gw"
Expand Down Expand Up @@ -270,9 +270,9 @@ var _ = Describe("wasm controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &gwRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &gwRoute.Spec.Rules[0], Name: "rule-1"},
})
actionSetName = fmt.Sprintf("%d-%s-%d", 0, pathID, 0) // Hostname: 0, HTTPRouteMatch: 0
actionSetName = wasm.ActionSetNameForPath(pathID, 1, string(gwRoute.Spec.Hostnames[0]))

routePolicy = policyFactory(func(policy *kuadrantv1beta3.RateLimitPolicy) {
policy.Name = "route"
Expand Down
75 changes: 37 additions & 38 deletions tests/istio/extension_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ package istio_test

import (
"context"
"fmt"
"reflect"
"time"

Expand Down Expand Up @@ -95,7 +94,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// create ratelimitpolicy
Expand Down Expand Up @@ -156,7 +155,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -304,13 +303,13 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
}
httpRouteRuleToys := &machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute}
httpRouteRuleAssets := &machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[1], HTTPRoute: mHTTPRoute}
httpRouteRuleToys := &machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"}
httpRouteRuleAssets := &machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[1], Name: "rule-2"}

// GET api.toystore.io/toys*
actionSet := existingWASMConfig.ActionSets[0]
pathID := kuadrantv1.PathID(append(basePath, httpRouteRuleToys))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 1, pathID, 0))) // Hostname: 1, HTTPRouteMatch: 0
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 1, "api.toystore.io")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"api.toystore.io"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -373,7 +372,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
// POST api.toystore.io/toys*
actionSet = existingWASMConfig.ActionSets[1]
pathID = kuadrantv1.PathID(append(basePath, httpRouteRuleToys))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 1, pathID, 1))) // Hostname: 1, HTTPRouteMatch: 1
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 2, "api.toystore.io")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"api.toystore.io"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -436,7 +435,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
// api.toystore.io/assets*
actionSet = existingWASMConfig.ActionSets[2]
pathID = kuadrantv1.PathID(append(basePath, httpRouteRuleAssets))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 1, pathID, 2))) // Hostname: 1, HTTPRouteMatch: 2
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 3, "api.toystore.io")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"api.toystore.io"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -494,7 +493,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
// GET *.toystore.acme.com/toys*
actionSet = existingWASMConfig.ActionSets[3]
pathID = kuadrantv1.PathID(append(basePath, httpRouteRuleToys))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 0, pathID, 0))) // Hostname: 0, HTTPRouteMatch: 0
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 1, "*.toystore.acme.com")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"*.toystore.acme.com"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -557,7 +556,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
// POST *.toystore.acme.com/toys*
actionSet = existingWASMConfig.ActionSets[4]
pathID = kuadrantv1.PathID(append(basePath, httpRouteRuleToys))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 0, pathID, 1))) // Hostname: 0, HTTPRouteMatch: 1
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 2, "*.toystore.acme.com")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"*.toystore.acme.com"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -620,7 +619,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
// *.toystore.acme.com/assets*
actionSet = existingWASMConfig.ActionSets[5]
pathID = kuadrantv1.PathID(append(basePath, httpRouteRuleAssets))
Expect(actionSet.Name).To(Equal(fmt.Sprintf("%d-%s-%d", 0, pathID, 2))) // Hostname: 0, HTTPRouteMatch: 2
Expect(actionSet.Name).To(Equal(wasm.ActionSetNameForPath(pathID, 3, "*.toystore.acme.com")))
Expect(actionSet.RouteRuleConditions.Hostnames).To(Equal([]string{"*.toystore.acme.com"}))
Expect(actionSet.RouteRuleConditions.Matches).To(ContainElements(
wasm.Predicate{
Expand Down Expand Up @@ -690,7 +689,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// create ratelimitpolicy
Expand Down Expand Up @@ -746,7 +745,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -938,7 +937,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// Initial state set.
Expand Down Expand Up @@ -970,9 +969,9 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*"},
Hostnames: []string{"*.example.com"},
Matches: []wasm.Predicate{
{
Selector: "request.method",
Expand Down Expand Up @@ -1118,7 +1117,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// create RLP A -> Route A
Expand Down Expand Up @@ -1183,7 +1182,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -1283,7 +1282,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// Check wasm plugin for gateway B has configuration from the route
Expand Down Expand Up @@ -1314,7 +1313,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -1485,7 +1484,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRouteA.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRouteA.Spec.Rules[0], Name: "rule-1"},
})

// Initial state set.
Expand Down Expand Up @@ -1517,7 +1516,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.a.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.a.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -1580,7 +1579,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRouteB.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRouteB.Spec.Rules[0], Name: "rule-1"},
})

// Check wasm plugin has configuration from the route B
Expand Down Expand Up @@ -1611,7 +1610,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.b.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.b.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -1757,7 +1756,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRouteA.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRouteA.Spec.Rules[0], Name: "rule-1"},
})

// Initial state set.
Expand Down Expand Up @@ -1789,9 +1788,9 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.a.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*"},
Hostnames: []string{"*.a.example.com"},
Matches: []wasm.Predicate{
{
Selector: "request.method",
Expand Down Expand Up @@ -1901,7 +1900,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.a.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.a.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -2083,7 +2082,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRouteA.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRouteA.Spec.Rules[0], Name: "rule-1"},
})

// Initial state set.
Expand Down Expand Up @@ -2115,7 +2114,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, "*.a.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.a.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -2211,7 +2210,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRouteB.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRouteB.Spec.Rules[0], Name: "rule-1"},
})

expectedPlugin := &wasm.Config{
Expand All @@ -2224,7 +2223,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0), // Route A affected by RLP 1 -> Route A
Name: wasm.ActionSetNameForPath(pathID, 1, "*.a.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*.a.example.com"},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -2258,9 +2257,9 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
},
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID_B, 0), // Route B affected by RLP 1 -> Gateway
Name: wasm.ActionSetNameForPath(pathID_B, 1, "*.b.example.com"),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{"*"},
Hostnames: []string{"*.b.example.com"},
Matches: []wasm.Predicate{
{
Selector: "request.method",
Expand Down Expand Up @@ -2378,7 +2377,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

// Check wasm plugin
Expand All @@ -2400,7 +2399,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, gwHostname),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{gwHostname},
Matches: []wasm.Predicate{
Expand Down Expand Up @@ -2466,7 +2465,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
mGateway,
&machinery.Listener{Listener: &gateway.Spec.Listeners[0], Gateway: mGateway},
mHTTPRoute,
&machinery.HTTPRouteRule{HTTPRouteRule: &httpRoute.Spec.Rules[0], HTTPRoute: mHTTPRoute},
&machinery.HTTPRouteRule{HTTPRoute: mHTTPRoute, HTTPRouteRule: &httpRoute.Spec.Rules[0], Name: "rule-1"},
})

return &wasm.Config{
Expand All @@ -2479,7 +2478,7 @@ var _ = Describe("Rate Limiting WasmPlugin controller", func() {
},
ActionSets: []wasm.ActionSet{
{
Name: fmt.Sprintf("%d-%s-%d", 0, pathID, 0),
Name: wasm.ActionSetNameForPath(pathID, 1, hostname),
RouteRuleConditions: wasm.RouteRuleConditions{
Hostnames: []string{hostname},
Matches: []wasm.Predicate{
Expand Down

0 comments on commit 1d18a33

Please sign in to comment.