From 2dac9cbdfb874445540f33b15e61fc0979add22c Mon Sep 17 00:00:00 2001 From: Jacek Ewertowski Date: Wed, 18 Sep 2024 11:55:45 +0200 Subject: [PATCH] Add make target for fixing imports Signed-off-by: Jacek Ewertowski --- Makefile | 6 +++++- cmd/federation-controller/main.go | 15 ++++++++------- .../federation/v1alpha1/exported_service.pb.go | 5 +++-- internal/pkg/common/match_exported.go | 3 ++- internal/pkg/fds/exported_service_generator.go | 9 +++++---- .../pkg/fds/exported_service_generator_test.go | 7 ++++--- internal/pkg/fds/import_handler.go | 5 +++-- .../pkg/informer/service_export_event_handler.go | 5 +++-- .../informer/service_export_event_handler_test.go | 5 +++-- internal/pkg/mcp/destination_rule_generator.go | 5 +++-- internal/pkg/mcp/gateway_generator.go | 5 +++-- internal/pkg/mcp/gateway_generator_test.go | 3 ++- internal/pkg/mcp/service_entry_generator.go | 5 +++-- internal/pkg/mcp/service_entry_generator_test.go | 11 ++++++----- internal/pkg/mcp/virtual_service_generator.go | 5 +++-- internal/pkg/mcp/workload_entry_generator.go | 5 +++-- internal/pkg/mcp/workload_entry_generator_test.go | 9 +++++---- internal/pkg/xds/adss/adss_handler.go | 3 ++- internal/pkg/xds/adss/grpc_server.go | 3 ++- test/e2e/main_test.go | 2 +- 20 files changed, 69 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index a019143..c8fb054 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OUT := $(shell pwd) default: build test export TAG ?= latest -export HUB ?= quay.io/openshift-service-mesh +export HUB ?= quay.io/jewertow export ISTIO_VERSION ?= 1.23.0 .PHONY: build @@ -54,6 +54,10 @@ e2e-test: .PHONY: e2e e2e: kind-clusters e2e-test +.PHONY: fix-imports +fix-imports: + goimports -local "github.com/openshift-service-mesh/federation" -w . + LICENSE_FILE := /tmp/license.txt GO_FILES := $(shell find . -name '*.go') diff --git a/cmd/federation-controller/main.go b/cmd/federation-controller/main.go index ba55c88..c2637e5 100644 --- a/cmd/federation-controller/main.go +++ b/cmd/federation-controller/main.go @@ -24,6 +24,14 @@ import ( "syscall" discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" + "github.com/spf13/cobra" + istiolog "istio.io/istio/pkg/log" + corev1 "k8s.io/api/core/v1" + "k8s.io/client-go/informers" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "k8s.io/utils/env" + "github.com/openshift-service-mesh/federation/internal/pkg/config" "github.com/openshift-service-mesh/federation/internal/pkg/fds" "github.com/openshift-service-mesh/federation/internal/pkg/informer" @@ -32,13 +40,6 @@ import ( "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adsc" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "github.com/spf13/cobra" - istiolog "istio.io/istio/pkg/log" - corev1 "k8s.io/api/core/v1" - "k8s.io/client-go/informers" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/rest" - "k8s.io/utils/env" ) // Global variable to store the parsed commandline arguments diff --git a/internal/api/federation/v1alpha1/exported_service.pb.go b/internal/api/federation/v1alpha1/exported_service.pb.go index bd4dac3..22f0d82 100644 --- a/internal/api/federation/v1alpha1/exported_service.pb.go +++ b/internal/api/federation/v1alpha1/exported_service.pb.go @@ -21,10 +21,11 @@ package v1alpha1 import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" sync "sync" + + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" ) const ( diff --git a/internal/pkg/common/match_exported.go b/internal/pkg/common/match_exported.go index 35ed4b6..2a31645 100644 --- a/internal/pkg/common/match_exported.go +++ b/internal/pkg/common/match_exported.go @@ -15,9 +15,10 @@ package common import ( - "github.com/openshift-service-mesh/federation/internal/pkg/config" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" + + "github.com/openshift-service-mesh/federation/internal/pkg/config" ) func MatchExportRules(svc *corev1.Service, exportedLabelSelectors []config.LabelSelectors) bool { diff --git a/internal/pkg/fds/exported_service_generator.go b/internal/pkg/fds/exported_service_generator.go index 69a9b59..eeef39d 100644 --- a/internal/pkg/fds/exported_service_generator.go +++ b/internal/pkg/fds/exported_service_generator.go @@ -18,14 +18,15 @@ import ( "fmt" "strings" - "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" - "github.com/openshift-service-mesh/federation/internal/pkg/config" - "github.com/openshift-service-mesh/federation/internal/pkg/xds" - "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" "google.golang.org/protobuf/proto" "google.golang.org/protobuf/types/known/anypb" "k8s.io/apimachinery/pkg/labels" v1 "k8s.io/client-go/listers/core/v1" + + "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" + "github.com/openshift-service-mesh/federation/internal/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/xds" + "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" ) var _ adss.RequestHandler = (*ExportedServicesGenerator)(nil) diff --git a/internal/pkg/fds/exported_service_generator_test.go b/internal/pkg/fds/exported_service_generator_test.go index 3c634ac..5df3a13 100644 --- a/internal/pkg/fds/exported_service_generator_test.go +++ b/internal/pkg/fds/exported_service_generator_test.go @@ -18,15 +18,16 @@ import ( "reflect" "testing" - "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" - "github.com/openshift-service-mesh/federation/internal/pkg/config" - "github.com/openshift-service-mesh/federation/internal/pkg/informer" "golang.org/x/net/context" "google.golang.org/protobuf/types/known/anypb" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" + + "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" + "github.com/openshift-service-mesh/federation/internal/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/informer" ) var ( diff --git a/internal/pkg/fds/import_handler.go b/internal/pkg/fds/import_handler.go index 6ef06e8..1cfcf97 100644 --- a/internal/pkg/fds/import_handler.go +++ b/internal/pkg/fds/import_handler.go @@ -17,11 +17,12 @@ package fds import ( "fmt" + "google.golang.org/protobuf/proto" + "google.golang.org/protobuf/types/known/anypb" + "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adsc" - "google.golang.org/protobuf/proto" - "google.golang.org/protobuf/types/known/anypb" ) var _ adsc.ResponseHandler = (*ImportedServiceHandler)(nil) diff --git a/internal/pkg/informer/service_export_event_handler.go b/internal/pkg/informer/service_export_event_handler.go index d095523..ed3c4bf 100644 --- a/internal/pkg/informer/service_export_event_handler.go +++ b/internal/pkg/informer/service_export_event_handler.go @@ -15,11 +15,12 @@ package informer import ( + corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/runtime" + "github.com/openshift-service-mesh/federation/internal/pkg/common" "github.com/openshift-service-mesh/federation/internal/pkg/config" "github.com/openshift-service-mesh/federation/internal/pkg/xds" - corev1 "k8s.io/api/core/v1" - "k8s.io/apimachinery/pkg/runtime" ) var _ Handler = (*ServiceExportEventHandler)(nil) diff --git a/internal/pkg/informer/service_export_event_handler_test.go b/internal/pkg/informer/service_export_event_handler_test.go index 9f9b1e1..b53ea1b 100644 --- a/internal/pkg/informer/service_export_event_handler_test.go +++ b/internal/pkg/informer/service_export_event_handler_test.go @@ -18,10 +18,11 @@ import ( "testing" "time" - "github.com/openshift-service-mesh/federation/internal/pkg/config" - "github.com/openshift-service-mesh/federation/internal/pkg/xds" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + "github.com/openshift-service-mesh/federation/internal/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/xds" ) var ( diff --git a/internal/pkg/mcp/destination_rule_generator.go b/internal/pkg/mcp/destination_rule_generator.go index 41e0297..0aa03ea 100644 --- a/internal/pkg/mcp/destination_rule_generator.go +++ b/internal/pkg/mcp/destination_rule_generator.go @@ -15,11 +15,12 @@ package mcp import ( + "google.golang.org/protobuf/types/known/anypb" + istiocfg "istio.io/istio/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "google.golang.org/protobuf/types/known/anypb" - istiocfg "istio.io/istio/pkg/config" ) var _ adss.RequestHandler = (*DestinationRuleResourceGenerator)(nil) diff --git a/internal/pkg/mcp/gateway_generator.go b/internal/pkg/mcp/gateway_generator.go index f5305b4..89a19ac 100644 --- a/internal/pkg/mcp/gateway_generator.go +++ b/internal/pkg/mcp/gateway_generator.go @@ -17,11 +17,12 @@ package mcp import ( "fmt" + "google.golang.org/protobuf/types/known/anypb" + istiocfg "istio.io/istio/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "google.golang.org/protobuf/types/known/anypb" - istiocfg "istio.io/istio/pkg/config" ) var _ adss.RequestHandler = (*GatewayResourceGenerator)(nil) diff --git a/internal/pkg/mcp/gateway_generator_test.go b/internal/pkg/mcp/gateway_generator_test.go index 1e86334..b254672 100644 --- a/internal/pkg/mcp/gateway_generator_test.go +++ b/internal/pkg/mcp/gateway_generator_test.go @@ -15,10 +15,11 @@ package mcp import ( - "github.com/openshift-service-mesh/federation/internal/pkg/fds" "reflect" "testing" + "github.com/openshift-service-mesh/federation/internal/pkg/fds" + "golang.org/x/net/context" istionetv1alpha3 "istio.io/api/networking/v1alpha3" istiocfg "istio.io/istio/pkg/config" diff --git a/internal/pkg/mcp/service_entry_generator.go b/internal/pkg/mcp/service_entry_generator.go index d7204f9..b3eb381 100644 --- a/internal/pkg/mcp/service_entry_generator.go +++ b/internal/pkg/mcp/service_entry_generator.go @@ -17,11 +17,12 @@ package mcp import ( "fmt" + "google.golang.org/protobuf/types/known/anypb" + istioconfig "istio.io/istio/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "google.golang.org/protobuf/types/known/anypb" - istioconfig "istio.io/istio/pkg/config" ) var _ adss.RequestHandler = (*ServiceEntryGenerator)(nil) diff --git a/internal/pkg/mcp/service_entry_generator_test.go b/internal/pkg/mcp/service_entry_generator_test.go index 8913c1a..8387ee3 100644 --- a/internal/pkg/mcp/service_entry_generator_test.go +++ b/internal/pkg/mcp/service_entry_generator_test.go @@ -20,11 +20,6 @@ import ( "strings" "testing" - "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" - "github.com/openshift-service-mesh/federation/internal/pkg/config" - "github.com/openshift-service-mesh/federation/internal/pkg/fds" - "github.com/openshift-service-mesh/federation/internal/pkg/informer" - "github.com/openshift-service-mesh/federation/internal/pkg/istio" "golang.org/x/net/context" "google.golang.org/protobuf/types/known/anypb" mcp "istio.io/api/mcp/v1alpha1" @@ -34,6 +29,12 @@ import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" + + "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" + "github.com/openshift-service-mesh/federation/internal/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/fds" + "github.com/openshift-service-mesh/federation/internal/pkg/informer" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" ) var ( diff --git a/internal/pkg/mcp/virtual_service_generator.go b/internal/pkg/mcp/virtual_service_generator.go index 079edf3..d07a9fe 100644 --- a/internal/pkg/mcp/virtual_service_generator.go +++ b/internal/pkg/mcp/virtual_service_generator.go @@ -15,11 +15,12 @@ package mcp import ( + "google.golang.org/protobuf/types/known/anypb" + istiocfg "istio.io/istio/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "google.golang.org/protobuf/types/known/anypb" - istiocfg "istio.io/istio/pkg/config" ) var _ adss.RequestHandler = (*VirtualServiceResourceGenerator)(nil) diff --git a/internal/pkg/mcp/workload_entry_generator.go b/internal/pkg/mcp/workload_entry_generator.go index 3ab4972..37c2f40 100644 --- a/internal/pkg/mcp/workload_entry_generator.go +++ b/internal/pkg/mcp/workload_entry_generator.go @@ -17,11 +17,12 @@ package mcp import ( "fmt" + "google.golang.org/protobuf/types/known/anypb" + istioconfig "istio.io/istio/pkg/config" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" "github.com/openshift-service-mesh/federation/internal/pkg/xds" "github.com/openshift-service-mesh/federation/internal/pkg/xds/adss" - "google.golang.org/protobuf/types/known/anypb" - istioconfig "istio.io/istio/pkg/config" ) var _ adss.RequestHandler = (*WorkloadEntryGenerator)(nil) diff --git a/internal/pkg/mcp/workload_entry_generator_test.go b/internal/pkg/mcp/workload_entry_generator_test.go index 7105227..1f62862 100644 --- a/internal/pkg/mcp/workload_entry_generator_test.go +++ b/internal/pkg/mcp/workload_entry_generator_test.go @@ -19,15 +19,16 @@ import ( "reflect" "testing" - "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" - "github.com/openshift-service-mesh/federation/internal/pkg/fds" - "github.com/openshift-service-mesh/federation/internal/pkg/informer" - "github.com/openshift-service-mesh/federation/internal/pkg/istio" istiocfg "istio.io/istio/pkg/config" corev1 "k8s.io/api/core/v1" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/informers" "k8s.io/client-go/kubernetes/fake" + + "github.com/openshift-service-mesh/federation/internal/api/federation/v1alpha1" + "github.com/openshift-service-mesh/federation/internal/pkg/fds" + "github.com/openshift-service-mesh/federation/internal/pkg/informer" + "github.com/openshift-service-mesh/federation/internal/pkg/istio" ) func TestWorkloadEntryGenerator(t *testing.T) { diff --git a/internal/pkg/xds/adss/adss_handler.go b/internal/pkg/xds/adss/adss_handler.go index 38ee378..08c12f8 100644 --- a/internal/pkg/xds/adss/adss_handler.go +++ b/internal/pkg/xds/adss/adss_handler.go @@ -26,11 +26,12 @@ import ( envoycfgcorev3 "github.com/envoyproxy/go-control-plane/envoy/config/core/v3" discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" - "github.com/openshift-service-mesh/federation/internal/pkg/xds" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" "google.golang.org/protobuf/types/known/anypb" istiolog "istio.io/istio/pkg/log" + + "github.com/openshift-service-mesh/federation/internal/pkg/xds" ) var log = istiolog.RegisterScope("adss", "Aggregated Discovery Service Server") diff --git a/internal/pkg/xds/adss/grpc_server.go b/internal/pkg/xds/adss/grpc_server.go index 9720160..fc38569 100644 --- a/internal/pkg/xds/adss/grpc_server.go +++ b/internal/pkg/xds/adss/grpc_server.go @@ -20,9 +20,10 @@ import ( "net" discovery "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3" - "github.com/openshift-service-mesh/federation/internal/pkg/xds" "golang.org/x/sync/errgroup" "google.golang.org/grpc" + + "github.com/openshift-service-mesh/federation/internal/pkg/xds" ) type Server struct { diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index ef0f594..0d9ba5e 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -50,7 +50,7 @@ var ( _, file, _, _ = runtime.Caller(0) rootDir = filepath.Join(filepath.Dir(file), "../..") - testHub = env.GetString("HUB", "quay.io/openshift-service-mesh") + testHub = env.GetString("HUB", "quay.io/jewertow") testTag = env.GetString("TAG", "latest") istioVersion = env.GetString("ISTIO_VERSION", "1.22.1")