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 Feb 20, 2024
1 parent 0d4005a commit 865c1c4
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 @@ -10,7 +10,7 @@ import (
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

policy2 "github.com/kuadrant/kuadrant-operator/pkg/library/utils"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
)

func testBuildBasicRLP(name string, kind gatewayapiv1.Kind) *RateLimitPolicy {
Expand Down Expand Up @@ -70,7 +70,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 @@ -9,13 +9,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

policy2 "github.com/kuadrant/kuadrant-operator/pkg/library/utils"
"github.com/kuadrant/kuadrant-operator/pkg/library/utils"
)

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 @@ -39,7 +39,7 @@ func ComputeGatewayDiffs(ctx context.Context, k8sClient client.Reader, policy, t
return nil, err
}

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())
}
Expand All @@ -60,11 +60,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 @@ -73,11 +73,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 @@ -86,11 +86,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 865c1c4

Please sign in to comment.