From 865c1c401b36cc6b1895c64ddeed4888b640a4e4 Mon Sep 17 00:00:00 2001 From: KevFan Date: Tue, 30 Jan 2024 12:55:51 +0000 Subject: [PATCH] refactor: fix redundant package rename --- api/v1beta2/ratelimitpolicy_types_test.go | 4 ++-- pkg/library/reconcilers/gateway_diffs.go | 28 +++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/api/v1beta2/ratelimitpolicy_types_test.go b/api/v1beta2/ratelimitpolicy_types_test.go index a2eba1eda..65ee7bcdc 100644 --- a/api/v1beta2/ratelimitpolicy_types_test.go +++ b/api/v1beta2/ratelimitpolicy_types_test.go @@ -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 { @@ -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") } diff --git a/pkg/library/reconcilers/gateway_diffs.go b/pkg/library/reconcilers/gateway_diffs.go index 29c8c1bbe..9e0c5b608 100644 --- a/pkg/library/reconcilers/gateway_diffs.go +++ b/pkg/library/reconcilers/gateway_diffs.go @@ -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. @@ -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()) } @@ -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) } @@ -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) } @@ -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) }