Skip to content

Commit

Permalink
refactor: fix redundant package rename
Browse files Browse the repository at this point in the history
  • Loading branch information
KevFan committed Jan 30, 2024
1 parent 89bb7a9 commit 73a12c3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions api/v1beta2/ratelimitpolicy_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
"testing"

policy2 "github.com/kuadrant/kuadrant-operator/pkg/library/utils"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"
Expand Down Expand Up @@ -69,7 +69,7 @@ func TestRateLimitPolicyListGetItems(t *testing.T) {
if len(result) != 1 {
t.Errorf("Expected 1 item, got %d", len(result))
}
_, ok := result[0].(policy2.KuadrantPolicy)
_, ok := result[0].(utils.KuadrantPolicy)
if !ok {
t.Errorf("Expected item to be a KuadrantPolicy")
}
Expand Down
28 changes: 14 additions & 14 deletions pkg/library/reconcilers/gateway_diffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import (
"slices"

"github.com/go-logr/logr"
policy2 "github.com/kuadrant/kuadrant-operator/pkg/library/utils"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)

type GatewayDiffs struct {
GatewaysMissingPolicyRef []policy2.GatewayWrapper
GatewaysWithValidPolicyRef []policy2.GatewayWrapper
GatewaysWithInvalidPolicyRef []policy2.GatewayWrapper
GatewaysMissingPolicyRef []utils.GatewayWrapper
GatewaysWithValidPolicyRef []utils.GatewayWrapper
GatewaysWithInvalidPolicyRef []utils.GatewayWrapper
}

// ComputeGatewayDiffs computes all the differences to reconcile regarding the gateways whose behaviors should/should not be extended by the policy.
Expand All @@ -38,7 +38,7 @@ func ComputeGatewayDiffs(ctx context.Context, k8sClient client.Reader, policy, t
return nil, err
}

Check warning on line 39 in pkg/library/reconcilers/gateway_diffs.go

View check run for this annotation

Codecov / codecov/patch

pkg/library/reconcilers/gateway_diffs.go#L35-L39

Added lines #L35 - L39 were not covered by tests

policyKind, ok := policy.(policy2.Referrer)
policyKind, ok := policy.(utils.Referrer)
if !ok {
return nil, fmt.Errorf("policy %s is not a referrer", policy.GetObjectKind().GroupVersionKind())
}

Check warning on line 44 in pkg/library/reconcilers/gateway_diffs.go

View check run for this annotation

Codecov / codecov/patch

pkg/library/reconcilers/gateway_diffs.go#L41-L44

Added lines #L41 - L44 were not covered by tests
Expand All @@ -59,11 +59,11 @@ func ComputeGatewayDiffs(ctx context.Context, k8sClient client.Reader, policy, t
}

// gatewaysMissingPolicyRef returns gateways referenced by the policy but that miss the reference to it the annotations
func gatewaysMissingPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind policy2.Referrer) []policy2.GatewayWrapper {
gateways := make([]policy2.GatewayWrapper, 0)
func gatewaysMissingPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind utils.Referrer) []utils.GatewayWrapper {
gateways := make([]utils.GatewayWrapper, 0)
for i := range gwList.Items {
gateway := gwList.Items[i]
gw := policy2.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
gw := utils.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
if slices.Contains(policyGwKeys, client.ObjectKeyFromObject(&gateway)) && !gw.ContainsPolicy(policyKey) {
gateways = append(gateways, gw)
}
Expand All @@ -72,11 +72,11 @@ func gatewaysMissingPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client
}

// gatewaysWithValidPolicyRef returns gateways referenced by the policy that also have the reference in the annotations
func gatewaysWithValidPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind policy2.Referrer) []policy2.GatewayWrapper {
gateways := make([]policy2.GatewayWrapper, 0)
func gatewaysWithValidPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind utils.Referrer) []utils.GatewayWrapper {
gateways := make([]utils.GatewayWrapper, 0)
for i := range gwList.Items {
gateway := gwList.Items[i]
gw := policy2.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
gw := utils.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
if slices.Contains(policyGwKeys, client.ObjectKeyFromObject(&gateway)) && gw.ContainsPolicy(policyKey) {
gateways = append(gateways, gw)
}
Expand All @@ -85,11 +85,11 @@ func gatewaysWithValidPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey clie
}

// gatewaysWithInvalidPolicyRef returns gateways not referenced by the policy that still have the reference in the annotations
func gatewaysWithInvalidPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind policy2.Referrer) []policy2.GatewayWrapper {
gateways := make([]policy2.GatewayWrapper, 0)
func gatewaysWithInvalidPolicyRef(gwList *gatewayapiv1.GatewayList, policyKey client.ObjectKey, policyGwKeys []client.ObjectKey, policyKind utils.Referrer) []utils.GatewayWrapper {
gateways := make([]utils.GatewayWrapper, 0)
for i := range gwList.Items {
gateway := gwList.Items[i]
gw := policy2.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
gw := utils.GatewayWrapper{Gateway: &gateway, Referrer: policyKind}
if !slices.Contains(policyGwKeys, client.ObjectKeyFromObject(&gateway)) && gw.ContainsPolicy(policyKey) {
gateways = append(gateways, gw)
}
Expand Down

0 comments on commit 73a12c3

Please sign in to comment.