Skip to content

Commit

Permalink
fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
eguzki committed Jun 6, 2024
1 parent 85eb0be commit 279b063
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion controllers/rate_limiting_istio_wasmplugin_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (r *RateLimitingIstioWASMPluginReconciler) wasmRateLimitPolicy(ctx context.
routeWithEffectiveHostnames := route.DeepCopy()
routeWithEffectiveHostnames.Spec.Hostnames = hostnames

rules := rlptools.WasmRules(rlp, routeWithEffectiveHostnames)
rules := wasm.Rules(rlp, routeWithEffectiveHostnames)

Check warning on line 231 in controllers/rate_limiting_istio_wasmplugin_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/rate_limiting_istio_wasmplugin_controller.go#L231

Added line #L231 was not covered by tests
if len(rules) == 0 {
// no need to add the policy if there are no rules; a rlp can return no rules if all its limits fail to match any route rule
return nil, nil
Expand Down
8 changes: 7 additions & 1 deletion controllers/ratelimitpolicy_enforced_status_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/library/fieldindexers"
kuadrantgatewayapi "github.com/kuadrant/kuadrant-operator/pkg/library/gatewayapi"
"github.com/kuadrant/kuadrant-operator/pkg/library/kuadrant"
"github.com/kuadrant/kuadrant-operator/pkg/library/mappers"
Expand Down Expand Up @@ -180,7 +181,12 @@ func (r *RateLimitPolicyEnforcedStatusReconciler) buildTopology(ctx context.Cont

routeList := &gatewayapiv1.HTTPRouteList{}
// Get all the routes having the gateway as parent
err = r.Client().List(ctx, routeList, client.MatchingFields{HTTPRouteGatewayParentField: client.ObjectKeyFromObject(gw).String()})
err = r.Client().List(
ctx,
routeList,
client.MatchingFields{
fieldindexers.HTTPRouteGatewayParentField: client.ObjectKeyFromObject(gw).String(),
})

Check warning on line 189 in controllers/ratelimitpolicy_enforced_status_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/ratelimitpolicy_enforced_status_controller.go#L184-L189

Added lines #L184 - L189 were not covered by tests
logger.V(1).Info("list routes by gateway", "#routes", len(routeList.Items), "err", err)
if err != nil {
return nil, err
Expand Down
9 changes: 7 additions & 2 deletions pkg/rlptools/topology_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TopologyIndexesFromGateway(ctx context.Context, cl client.Client, gw *gatew

policies := utils.Map(rlpList.Items, func(p kuadrantv1beta2.RateLimitPolicy) kuadrantgatewayapi.Policy { return &p })

Check warning on line 49 in pkg/rlptools/topology_index.go

View check run for this annotation

Codecov / codecov/patch

pkg/rlptools/topology_index.go#L49

Added line #L49 was not covered by tests

t, err := kuadrantgatewayapi.NewTopology(
topology, err := kuadrantgatewayapi.NewTopology(
kuadrantgatewayapi.WithGateways([]*gatewayapiv1.Gateway{gw}),
kuadrantgatewayapi.WithRoutes(utils.Map(routeList.Items, ptr.To)),
kuadrantgatewayapi.WithPolicies(policies),
Expand All @@ -58,5 +58,10 @@ func TopologyIndexesFromGateway(ctx context.Context, cl client.Client, gw *gatew
return nil, err

Check warning on line 58 in pkg/rlptools/topology_index.go

View check run for this annotation

Codecov / codecov/patch

pkg/rlptools/topology_index.go#L51-L58

Added lines #L51 - L58 were not covered by tests
}

return kuadrantgatewayapi.NewTopologyIndexes(t), nil
overriddenTopology, err := ApplyOverrides(topology, gw)
if err != nil {
return nil, err

Check warning on line 63 in pkg/rlptools/topology_index.go

View check run for this annotation

Codecov / codecov/patch

pkg/rlptools/topology_index.go#L61-L63

Added lines #L61 - L63 were not covered by tests
}

return kuadrantgatewayapi.NewTopologyIndexes(overriddenTopology), nil

Check warning on line 66 in pkg/rlptools/topology_index.go

View check run for this annotation

Codecov / codecov/patch

pkg/rlptools/topology_index.go#L66

Added line #L66 was not covered by tests
}
1 change: 0 additions & 1 deletion pkg/rlptools/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"

limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
Expand Down
1 change: 0 additions & 1 deletion pkg/rlptools/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
Expand Down
8 changes: 4 additions & 4 deletions pkg/rlptools/wasm/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import (
"crypto/sha256"
"encoding/hex"
"errors"
"fmt"
"slices"
"strings"
"unicode"

"github.com/samber/lo"
_struct "google.golang.org/protobuf/types/known/structpb"
istioclientgoextensionv1alpha1 "istio.io/client-go/pkg/apis/extensions/v1alpha1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/utils/env"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down Expand Up @@ -55,7 +55,7 @@ func Rules(rlp *kuadrantv1beta2.RateLimitPolicy, route *gatewayapiv1.HTTPRoute)
return rules
}

func LimitNameToLimitadorIdentifier(uniqueLimitName string) string {
func LimitNameToLimitadorIdentifier(rlpKey types.NamespacedName, uniqueLimitName string) string {
identifier := LimitadorRateLimitIdentifierPrefix

// sanitize chars that are not allowed in limitador identifiers
Expand All @@ -68,7 +68,7 @@ func LimitNameToLimitadorIdentifier(uniqueLimitName string) string {
}

// to avoid breaking the uniqueness of the limit name after sanitization, we add a hash of the original name
hash := sha256.Sum256([]byte(uniqueLimitName))
hash := sha256.Sum256([]byte(fmt.Sprintf("%s/%s", rlpKey.String(), uniqueLimitName)))
identifier += "__" + hex.EncodeToString(hash[:4])

return identifier
Expand Down
1 change: 1 addition & 0 deletions pkg/rlptools/wasm/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/google/go-cmp/cmp"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantv1beta2 "github.com/kuadrant/kuadrant-operator/api/v1beta2"
Expand Down

0 comments on commit 279b063

Please sign in to comment.