diff --git a/.github/workflows/lint-go.yml b/.github/workflows/lint-go.yml index ef99563..62e53b2 100644 --- a/.github/workflows/lint-go.yml +++ b/.github/workflows/lint-go.yml @@ -16,4 +16,4 @@ jobs: uses: kyma-project/eventing-tools/.github/workflows/lint-go-reusable.yml@main with: go-version: '1.21' - lint-config-uri: https://raw.githubusercontent.com/kyma-project/eventing-tools/ca5d5cc431d9fb5cd12e7ef4c6c82331f203c630/config/lint/.golangci.yaml + lint-config-uri: https://raw.githubusercontent.com/kyma-project/eventing-tools/bb304a7bc82577a23ed653a35592be97d5d02c41/config/lint/.golangci.yaml diff --git a/cmd/eventing-publisher-proxy/main.go b/cmd/eventing-publisher-proxy/main.go index 135abc3..0cdc28a 100644 --- a/cmd/eventing-publisher-proxy/main.go +++ b/cmd/eventing-publisher-proxy/main.go @@ -4,15 +4,15 @@ import ( log "log" "github.com/kelseyhightower/envconfig" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/prometheus/client_golang/prometheus" - "github.com/kyma-project/eventing-publisher-proxy/pkg/commander" "github.com/kyma-project/eventing-publisher-proxy/pkg/commander/eventmesh" "github.com/kyma-project/eventing-publisher-proxy/pkg/commander/nats" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/latency" "github.com/kyma-project/eventing-publisher-proxy/pkg/options" + "github.com/prometheus/client_golang/prometheus" + + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) const ( @@ -25,10 +25,10 @@ type Config struct { Backend string `envconfig:"BACKEND" required:"true"` // AppLogFormat defines the log format. - AppLogFormat string `envconfig:"APP_LOG_FORMAT" default:"json"` + AppLogFormat string `default:"json" envconfig:"APP_LOG_FORMAT"` // AppLogLevel defines the log level. - AppLogLevel string `envconfig:"APP_LOG_LEVEL" default:"info"` + AppLogLevel string `default:"info" envconfig:"APP_LOG_LEVEL"` } func main() { diff --git a/pkg/application/applicationtest/applicationtest.go b/pkg/application/applicationtest/applicationtest.go index c6ae127..006d4ad 100644 --- a/pkg/application/applicationtest/applicationtest.go +++ b/pkg/application/applicationtest/applicationtest.go @@ -2,9 +2,8 @@ package applicationtest import ( - kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" + kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) func NewApplication(name string, labels map[string]string) *kymaappconnv1alpha1.Application { diff --git a/pkg/application/clean_test.go b/pkg/application/clean_test.go index 267866d..d9e36ad 100644 --- a/pkg/application/clean_test.go +++ b/pkg/application/clean_test.go @@ -3,11 +3,9 @@ package application import ( "testing" - "github.com/stretchr/testify/require" - - kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" - "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" + kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" + "github.com/stretchr/testify/require" ) func TestCleanName(t *testing.T) { diff --git a/pkg/application/fake/lister.go b/pkg/application/fake/lister.go index c47e555..fb30cea 100644 --- a/pkg/application/fake/lister.go +++ b/pkg/application/fake/lister.go @@ -4,13 +4,11 @@ import ( "context" "log" + "github.com/kyma-project/eventing-publisher-proxy/pkg/application" + kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" kcorev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" kdynamicfake "k8s.io/client-go/dynamic/fake" - - kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" ) func NewApplicationListerOrDie(ctx context.Context, app *kymaappconnv1alpha1.Application) *application.Lister { diff --git a/pkg/application/lister.go b/pkg/application/lister.go index cc21d9d..ee1025c 100644 --- a/pkg/application/lister.go +++ b/pkg/application/lister.go @@ -5,7 +5,7 @@ import ( "errors" "time" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" + "github.com/kyma-project/eventing-publisher-proxy/pkg/informers" kymaappconnv1alpha1 "github.com/kyma-project/kyma/components/central-application-gateway/pkg/apis/applicationconnector/v1alpha1" kcorev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" @@ -15,7 +15,7 @@ import ( "k8s.io/client-go/dynamic/dynamicinformer" "k8s.io/client-go/tools/cache" - "github.com/kyma-project/eventing-publisher-proxy/pkg/informers" + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) type Lister struct { diff --git a/pkg/cloudevents/builder/eventmesh.go b/pkg/cloudevents/builder/eventmesh.go index 769c6a1..440b91d 100644 --- a/pkg/cloudevents/builder/eventmesh.go +++ b/pkg/cloudevents/builder/eventmesh.go @@ -2,11 +2,10 @@ package builder import ( ceevent "github.com/cloudevents/sdk-go/v2/event" + "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" "github.com/kyma-project/eventing-manager/pkg/logger" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" ) // Perform a compile-time check. diff --git a/pkg/cloudevents/builder/eventmesh_test.go b/pkg/cloudevents/builder/eventmesh_test.go index 330c268..f22ede8 100644 --- a/pkg/cloudevents/builder/eventmesh_test.go +++ b/pkg/cloudevents/builder/eventmesh_test.go @@ -8,13 +8,14 @@ import ( "testing" ce "github.com/cloudevents/sdk-go/v2" - "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/fake" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" "github.com/stretchr/testify/require" + + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) func Test_EventMesh_Build(t *testing.T) { diff --git a/pkg/cloudevents/builder/generic.go b/pkg/cloudevents/builder/generic.go index f80e6c4..e28b22a 100644 --- a/pkg/cloudevents/builder/generic.go +++ b/pkg/cloudevents/builder/generic.go @@ -5,12 +5,11 @@ import ( "strings" ceevent "github.com/cloudevents/sdk-go/v2/event" + "github.com/kyma-project/eventing-publisher-proxy/pkg/application" + "go.uber.org/zap" "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" ) // Perform a compile-time check. diff --git a/pkg/cloudevents/builder/generic_test.go b/pkg/cloudevents/builder/generic_test.go index b8bc929..20b0275 100644 --- a/pkg/cloudevents/builder/generic_test.go +++ b/pkg/cloudevents/builder/generic_test.go @@ -7,14 +7,14 @@ import ( "testing" ce "github.com/cloudevents/sdk-go/v2" - epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" - - "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/fake" + epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" "github.com/stretchr/testify/require" + + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) func Test_Build(t *testing.T) { diff --git a/pkg/cloudevents/builder/types.go b/pkg/cloudevents/builder/types.go index e23c07d..be0f8aa 100644 --- a/pkg/cloudevents/builder/types.go +++ b/pkg/cloudevents/builder/types.go @@ -2,9 +2,10 @@ package builder import ( ceevent "github.com/cloudevents/sdk-go/v2/event" + "github.com/kyma-project/eventing-publisher-proxy/pkg/application" + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" ) const ( diff --git a/pkg/cloudevents/eventtype/clean.go b/pkg/cloudevents/eventtype/clean.go index a276e95..acce369 100644 --- a/pkg/cloudevents/eventtype/clean.go +++ b/pkg/cloudevents/eventtype/clean.go @@ -3,12 +3,11 @@ package eventtype import ( "regexp" + "github.com/kyma-project/eventing-publisher-proxy/pkg/application" + "go.uber.org/zap" "golang.org/x/xerrors" "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" ) var ( diff --git a/pkg/cloudevents/eventtype/clean_test.go b/pkg/cloudevents/eventtype/clean_test.go index cb114ae..409f791 100644 --- a/pkg/cloudevents/eventtype/clean_test.go +++ b/pkg/cloudevents/eventtype/clean_test.go @@ -4,13 +4,12 @@ import ( "context" "testing" - "github.com/kyma-project/eventing-manager/pkg/logger" - - "github.com/stretchr/testify/require" - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/fake" + "github.com/stretchr/testify/require" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) //nolint:lll // we need long lines here as the event types can get very long diff --git a/pkg/cloudevents/utils.go b/pkg/cloudevents/utils.go index 6e5eb67..4ac2cee 100644 --- a/pkg/cloudevents/utils.go +++ b/pkg/cloudevents/utils.go @@ -4,10 +4,9 @@ import ( "context" "net/http" - "github.com/pkg/errors" - "github.com/cloudevents/sdk-go/v2/binding" cehttp "github.com/cloudevents/sdk-go/v2/protocol/http" + "github.com/pkg/errors" ) // WriteRequestWithHeaders writes a CloudEvent HTTP request with the given message and adds the given headers to it. diff --git a/pkg/cloudevents/utils_test.go b/pkg/cloudevents/utils_test.go index a7e8464..02a7e37 100644 --- a/pkg/cloudevents/utils_test.go +++ b/pkg/cloudevents/utils_test.go @@ -9,7 +9,6 @@ import ( "testing" cehttp "github.com/cloudevents/sdk-go/v2/protocol/http" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/eventmesh" ) diff --git a/pkg/commander/eventmesh/eventmesh.go b/pkg/commander/eventmesh/eventmesh.go index d367283..ae4ec95 100644 --- a/pkg/commander/eventmesh/eventmesh.go +++ b/pkg/commander/eventmesh/eventmesh.go @@ -4,8 +4,6 @@ import ( "context" "github.com/kelseyhightower/envconfig" - "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" - "github.com/kyma-project/eventing-manager/pkg/logger" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype" @@ -21,12 +19,15 @@ import ( "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/eventmesh" "github.com/kyma-project/eventing-publisher-proxy/pkg/signals" "github.com/kyma-project/eventing-publisher-proxy/pkg/subscribed" - "go.uber.org/zap" "golang.org/x/xerrors" "k8s.io/client-go/dynamic" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // TODO: remove as this is only used in a development setup "sigs.k8s.io/controller-runtime/pkg/client/config" + + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" + "github.com/kyma-project/eventing-manager/pkg/logger" + + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // TODO: remove as this is only used in a development setup ) const ( diff --git a/pkg/commander/nats/nats.go b/pkg/commander/nats/nats.go index 95bd1f6..733b345 100644 --- a/pkg/commander/nats/nats.go +++ b/pkg/commander/nats/nats.go @@ -4,8 +4,6 @@ import ( "context" "github.com/kelseyhightower/envconfig" - "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" - "github.com/kyma-project/eventing-manager/pkg/logger" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype" @@ -20,12 +18,15 @@ import ( "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/jetstream" "github.com/kyma-project/eventing-publisher-proxy/pkg/signals" "github.com/kyma-project/eventing-publisher-proxy/pkg/subscribed" - "go.uber.org/zap" "golang.org/x/xerrors" "k8s.io/client-go/dynamic" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // TODO: remove as this is only required in a dev setup "sigs.k8s.io/controller-runtime/pkg/client/config" + + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" + "github.com/kyma-project/eventing-manager/pkg/logger" + + _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // TODO: remove as this is only required in a dev setup ) const ( diff --git a/pkg/env/eventmesh_config.go b/pkg/env/eventmesh_config.go index 4c058f9..457f6e8 100644 --- a/pkg/env/eventmesh_config.go +++ b/pkg/env/eventmesh_config.go @@ -11,20 +11,20 @@ var _ fmt.Stringer = &EventMeshConfig{} // EventMeshConfig represents the environment config for the Event Publisher to EventMesh. type EventMeshConfig struct { - Port int `envconfig:"INGRESS_PORT" default:"8080"` - ClientID string `envconfig:"CLIENT_ID" required:"true"` - ClientSecret string `envconfig:"CLIENT_SECRET" required:"true"` - TokenEndpoint string `envconfig:"TOKEN_ENDPOINT" required:"true"` + Port int `default:"8080" envconfig:"INGRESS_PORT"` + ClientID string `envconfig:"CLIENT_ID" required:"true"` + ClientSecret string `envconfig:"CLIENT_SECRET" required:"true"` + TokenEndpoint string `envconfig:"TOKEN_ENDPOINT" required:"true"` EventMeshPublishURL string `envconfig:"EMS_PUBLISH_URL" required:"true"` - MaxIdleConns int `envconfig:"MAX_IDLE_CONNS" default:"100"` - MaxIdleConnsPerHost int `envconfig:"MAX_IDLE_CONNS_PER_HOST" default:"2"` - RequestTimeout time.Duration `envconfig:"REQUEST_TIMEOUT" default:"5s"` + MaxIdleConns int `default:"100" envconfig:"MAX_IDLE_CONNS"` + MaxIdleConnsPerHost int `default:"2" envconfig:"MAX_IDLE_CONNS_PER_HOST"` + RequestTimeout time.Duration `default:"5s" envconfig:"REQUEST_TIMEOUT"` // EventMeshNamespace is the name of the namespace in EventMesh which is used as the event source for legacy events. EventMeshNamespace string `envconfig:"BEB_NAMESPACE" required:"true"` // EventTypePrefix is the prefix of each event as per the eventing specification. // It follows the eventType format: ... - EventTypePrefix string `envconfig:"EVENT_TYPE_PREFIX" default:""` - ApplicationCRDEnabled bool `envconfig:"APPLICATION_CRD_ENABLED" default:"true"` + EventTypePrefix string `default:"" envconfig:"EVENT_TYPE_PREFIX"` + ApplicationCRDEnabled bool `default:"true" envconfig:"APPLICATION_CRD_ENABLED"` } // ConfigureTransport receives an HTTP transport and configure its max idle connection properties. diff --git a/pkg/env/nats_config.go b/pkg/env/nats_config.go index 671b0b6..7ab5beb 100644 --- a/pkg/env/nats_config.go +++ b/pkg/env/nats_config.go @@ -12,22 +12,22 @@ const JetStreamSubjectPrefix = "kyma" // NATSConfig represents the environment config for the Event Publisher to NATS. type NATSConfig struct { - Port int `envconfig:"INGRESS_PORT" default:"8080"` + Port int `default:"8080" envconfig:"INGRESS_PORT"` URL string `envconfig:"NATS_URL" required:"true"` - RetryOnFailedConnect bool `envconfig:"RETRY_ON_FAILED_CONNECT" default:"true"` - MaxReconnects int `envconfig:"MAX_RECONNECTS" default:"-1"` // Negative means keep try reconnecting. - ReconnectWait time.Duration `envconfig:"RECONNECT_WAIT" default:"5s"` - RequestTimeout time.Duration `envconfig:"REQUEST_TIMEOUT" default:"5s"` - ApplicationCRDEnabled bool `envconfig:"APPLICATION_CRD_ENABLED" default:"true"` + RetryOnFailedConnect bool `default:"true" envconfig:"RETRY_ON_FAILED_CONNECT"` + MaxReconnects int `default:"-1" envconfig:"MAX_RECONNECTS"` // Negative means keep try reconnecting. + ReconnectWait time.Duration `default:"5s" envconfig:"RECONNECT_WAIT"` + RequestTimeout time.Duration `default:"5s" envconfig:"REQUEST_TIMEOUT"` + ApplicationCRDEnabled bool `default:"true" envconfig:"APPLICATION_CRD_ENABLED"` // Legacy Namespace is used as the event source for legacy events - LegacyNamespace string `envconfig:"LEGACY_NAMESPACE" default:"kyma"` + LegacyNamespace string `default:"kyma" envconfig:"LEGACY_NAMESPACE"` // EventTypePrefix is the prefix of each event as per the eventing specification // It follows the eventType format: ... - EventTypePrefix string `envconfig:"EVENT_TYPE_PREFIX" default:"kyma"` + EventTypePrefix string `default:"kyma" envconfig:"EVENT_TYPE_PREFIX"` // JetStream-specific configs - JSStreamName string `envconfig:"JS_STREAM_NAME" default:"kyma"` + JSStreamName string `default:"kyma" envconfig:"JS_STREAM_NAME"` } // ToConfig converts to a default EventMeshConfig. diff --git a/pkg/handler/handler.go b/pkg/handler/handler.go index 830a9d9..ce98718 100644 --- a/pkg/handler/handler.go +++ b/pkg/handler/handler.go @@ -7,29 +7,26 @@ import ( "strings" "time" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" - "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" - - "github.com/gorilla/mux" - "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - "github.com/cloudevents/sdk-go/v2/binding" ceclient "github.com/cloudevents/sdk-go/v2/client" ceevent "github.com/cloudevents/sdk-go/v2/event" cehttp "github.com/cloudevents/sdk-go/v2/protocol/http" - + "github.com/gorilla/mux" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype" + "github.com/kyma-project/eventing-publisher-proxy/pkg/env" "github.com/kyma-project/eventing-publisher-proxy/pkg/handler/health" "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" + "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" + "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" "github.com/kyma-project/eventing-publisher-proxy/pkg/options" "github.com/kyma-project/eventing-publisher-proxy/pkg/receiver" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" "github.com/kyma-project/eventing-publisher-proxy/pkg/subscribed" "github.com/kyma-project/eventing-publisher-proxy/pkg/tracing" + "go.uber.org/zap" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) // EventingHandler is responsible for receiving HTTP requests and dispatching them to the Backend. diff --git a/pkg/handler/handler_test.go b/pkg/handler/handler_test.go index 32c4e80..d8df91d 100644 --- a/pkg/handler/handler_test.go +++ b/pkg/handler/handler_test.go @@ -9,30 +9,27 @@ import ( "strings" "testing" - "github.com/stretchr/testify/require" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" - "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" - "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/legacytest" - "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" - "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/jetstream" - - "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/stretchr/testify/assert" - "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/fake" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" - "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype/eventtypetest" + "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" + "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" + "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/legacytest" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/histogram/mocks" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/metricstest" "github.com/kyma-project/eventing-publisher-proxy/pkg/options" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" + "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" + "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/jetstream" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kyma-project/eventing-manager/pkg/backend/cleaner" + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) func TestHandler_publishCloudEvents(t *testing.T) { diff --git a/pkg/handler/handler_v1alpha1_test.go b/pkg/handler/handler_v1alpha1_test.go index bed8c53..df75f30 100644 --- a/pkg/handler/handler_v1alpha1_test.go +++ b/pkg/handler/handler_v1alpha1_test.go @@ -13,18 +13,13 @@ import ( "testing" "time" - "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" - "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" - ce "github.com/cloudevents/sdk-go/v2" "github.com/cloudevents/sdk-go/v2/client" ceevent "github.com/cloudevents/sdk-go/v2/event" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/stretchr/testify/assert" - "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/fake" + "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/builder" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents/eventtype/eventtypetest" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" @@ -32,7 +27,11 @@ import ( "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/metricstest" "github.com/kyma-project/eventing-publisher-proxy/pkg/options" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" + "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "github.com/stretchr/testify/assert" + + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) func Test_extractCloudEventFromRequest(t *testing.T) { diff --git a/pkg/informers/sync.go b/pkg/informers/sync.go index 19eb3d2..a3db7ea 100644 --- a/pkg/informers/sync.go +++ b/pkg/informers/sync.go @@ -4,10 +4,10 @@ import ( "context" "time" - "github.com/kyma-project/eventing-manager/pkg/logger" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/client-go/dynamic/dynamicinformer" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) const ( diff --git a/pkg/legacy/helpers.go b/pkg/legacy/helpers.go index f9a686b..5ebee17 100644 --- a/pkg/legacy/helpers.go +++ b/pkg/legacy/helpers.go @@ -6,10 +6,10 @@ import ( "net/http" "strings" - emlogger "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" + + emlogger "github.com/kyma-project/eventing-manager/pkg/logger" ) const ( diff --git a/pkg/legacy/legacy.go b/pkg/legacy/legacy.go index f77c745..41e1286 100644 --- a/pkg/legacy/legacy.go +++ b/pkg/legacy/legacy.go @@ -10,11 +10,10 @@ import ( ceevent "github.com/cloudevents/sdk-go/v2/event" "github.com/google/uuid" - "github.com/pkg/errors" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" eppapi "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" + "github.com/pkg/errors" ) var ( diff --git a/pkg/legacy/legacy_test.go b/pkg/legacy/legacy_test.go index 74a6004..af20792 100644 --- a/pkg/legacy/legacy_test.go +++ b/pkg/legacy/legacy_test.go @@ -9,10 +9,6 @@ import ( "time" ceevent "github.com/cloudevents/sdk-go/v2/event" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/application" "github.com/kyma-project/eventing-publisher-proxy/pkg/application/applicationtest" @@ -20,6 +16,8 @@ import ( eppapi "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/api" "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy/legacytest" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" ) const ( diff --git a/pkg/metrics/collector.go b/pkg/metrics/collector.go index b4f331e..68e4a7f 100644 --- a/pkg/metrics/collector.go +++ b/pkg/metrics/collector.go @@ -6,10 +6,9 @@ import ( "time" "github.com/gorilla/mux" + "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/histogram" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/histogram" ) const ( diff --git a/pkg/metrics/collector_test.go b/pkg/metrics/collector_test.go index 09f6604..e6524ff 100644 --- a/pkg/metrics/collector_test.go +++ b/pkg/metrics/collector_test.go @@ -8,11 +8,10 @@ import ( "time" "github.com/gorilla/mux" - "github.com/prometheus/client_golang/prometheus/testutil" - "github.com/stretchr/testify/assert" - "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/histogram/mocks" "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics/latency" + "github.com/prometheus/client_golang/prometheus/testutil" + "github.com/stretchr/testify/assert" ) func TestNewCollector(t *testing.T) { diff --git a/pkg/metrics/metricstest/metricstest.go b/pkg/metrics/metricstest/metricstest.go index 3abf504..cb074cc 100644 --- a/pkg/metrics/metricstest/metricstest.go +++ b/pkg/metrics/metricstest/metricstest.go @@ -7,10 +7,9 @@ import ( "testing" "time" + "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/testutil" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/metrics" ) // EnsureMetricLatency ensures metric eventing_epp_backend_duration_seconds exists. diff --git a/pkg/nats/connect_test.go b/pkg/nats/connect_test.go index baff9ac..38f4042 100644 --- a/pkg/nats/connect_test.go +++ b/pkg/nats/connect_test.go @@ -4,12 +4,10 @@ import ( "testing" "time" - natsgo "github.com/nats-io/nats.go" - - "github.com/stretchr/testify/assert" - eppnats "github.com/kyma-project/eventing-publisher-proxy/pkg/nats" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + natsgo "github.com/nats-io/nats.go" + "github.com/stretchr/testify/assert" ) func TestConnect(t *testing.T) { diff --git a/pkg/oauth/client.go b/pkg/oauth/client.go index ae04cb5..3f56fce 100644 --- a/pkg/oauth/client.go +++ b/pkg/oauth/client.go @@ -4,11 +4,10 @@ import ( "context" "net/http" - "go.opencensus.io/plugin/ochttp" - "golang.org/x/oauth2" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" "github.com/kyma-project/eventing-publisher-proxy/pkg/tracing/propagation/tracecontextb3" + "go.opencensus.io/plugin/ochttp" + "golang.org/x/oauth2" ) // NewClient returns a new HTTP client which have nested transports for handling oauth2 security, diff --git a/pkg/oauth/client_test.go b/pkg/oauth/client_test.go index 2b38e63..cff54ae 100644 --- a/pkg/oauth/client_test.go +++ b/pkg/oauth/client_test.go @@ -7,11 +7,10 @@ import ( "testing" "time" - "go.opencensus.io/plugin/ochttp" - "golang.org/x/oauth2" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "go.opencensus.io/plugin/ochttp" + "golang.org/x/oauth2" ) func TestNewClient(t *testing.T) { diff --git a/pkg/oauth/config.go b/pkg/oauth/config.go index 6f0bfba..bfa223c 100644 --- a/pkg/oauth/config.go +++ b/pkg/oauth/config.go @@ -1,9 +1,8 @@ package oauth import ( - "golang.org/x/oauth2/clientcredentials" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" + "golang.org/x/oauth2/clientcredentials" ) // Config returns a new oauth2 client credentials config instance. diff --git a/pkg/receiver/receiver_test.go b/pkg/receiver/receiver_test.go index 2fefdaf..3ee1246 100644 --- a/pkg/receiver/receiver_test.go +++ b/pkg/receiver/receiver_test.go @@ -7,9 +7,9 @@ import ( "testing" "time" - "github.com/kyma-project/eventing-manager/pkg/logger" - epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) // a mocked http.Handler. diff --git a/pkg/sender/eventmesh/eventmesh.go b/pkg/sender/eventmesh/eventmesh.go index 2353419..91c984f 100644 --- a/pkg/sender/eventmesh/eventmesh.go +++ b/pkg/sender/eventmesh/eventmesh.go @@ -7,16 +7,15 @@ import ( "github.com/cloudevents/sdk-go/v2/binding" ceevent "github.com/cloudevents/sdk-go/v2/event" - - "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/cloudevents" "github.com/kyma-project/eventing-publisher-proxy/pkg/eventmesh" "github.com/kyma-project/eventing-publisher-proxy/pkg/handler/health" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" + "go.uber.org/zap" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) var _ sender.GenericSender = &Sender{} diff --git a/pkg/sender/eventmesh/eventmesh_test.go b/pkg/sender/eventmesh/eventmesh_test.go index 3debacf..ebc9b26 100644 --- a/pkg/sender/eventmesh/eventmesh_test.go +++ b/pkg/sender/eventmesh/eventmesh_test.go @@ -8,15 +8,15 @@ import ( "testing" "time" - "github.com/kyma-project/eventing-manager/pkg/logger" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" "github.com/kyma-project/eventing-publisher-proxy/pkg/oauth" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) const ( diff --git a/pkg/sender/jetstream/health.go b/pkg/sender/jetstream/health.go index d5d5439..92af955 100644 --- a/pkg/sender/jetstream/health.go +++ b/pkg/sender/jetstream/health.go @@ -3,9 +3,8 @@ package jetstream import ( "net/http" - "github.com/nats-io/nats.go" - "github.com/kyma-project/eventing-publisher-proxy/pkg/handler/health" + "github.com/nats-io/nats.go" ) // ReadinessCheck returns an instance of http.HandlerFunc that checks the readiness of the given NATS Handler. diff --git a/pkg/sender/jetstream/jetstream.go b/pkg/sender/jetstream/jetstream.go index befa750..f274462 100644 --- a/pkg/sender/jetstream/jetstream.go +++ b/pkg/sender/jetstream/jetstream.go @@ -8,20 +8,17 @@ import ( "net/http" "strings" - "github.com/nats-io/nats.go" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/options" - - "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - "github.com/cloudevents/sdk-go/v2/event" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/env" "github.com/kyma-project/eventing-publisher-proxy/pkg/handler/health" + "github.com/kyma-project/eventing-publisher-proxy/pkg/options" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender" "github.com/kyma-project/eventing-publisher-proxy/pkg/sender/common" + "github.com/nats-io/nats.go" + "go.uber.org/zap" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) const ( diff --git a/pkg/sender/jetstream/jetstream_test.go b/pkg/sender/jetstream/jetstream_test.go index c50dc4e..4787404 100644 --- a/pkg/sender/jetstream/jetstream_test.go +++ b/pkg/sender/jetstream/jetstream_test.go @@ -7,22 +7,17 @@ import ( "testing" "time" - natsgo "github.com/nats-io/nats.go" - - "github.com/kyma-project/eventing-manager/pkg/logger" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/options" - - "github.com/stretchr/testify/require" - - "github.com/cloudevents/sdk-go/v2/event" - ce "github.com/cloudevents/sdk-go/v2" + "github.com/cloudevents/sdk-go/v2/event" + "github.com/kyma-project/eventing-publisher-proxy/pkg/env" + "github.com/kyma-project/eventing-publisher-proxy/pkg/options" + epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" "github.com/nats-io/nats-server/v2/server" + natsgo "github.com/nats-io/nats.go" "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" - "github.com/kyma-project/eventing-publisher-proxy/pkg/env" - epptestingutils "github.com/kyma-project/eventing-publisher-proxy/testing" + "github.com/kyma-project/eventing-manager/pkg/logger" ) func TestJetStreamMessageSender(t *testing.T) { diff --git a/pkg/subscribed/helpers.go b/pkg/subscribed/helpers.go index 3067283..e5057f6 100644 --- a/pkg/subscribed/helpers.go +++ b/pkg/subscribed/helpers.go @@ -4,7 +4,7 @@ import ( "fmt" "strings" - emeventingv2alpha1 "github.com/kyma-project/eventing-manager/api/eventing/v1alpha2" + "github.com/kyma-project/eventing-publisher-proxy/pkg/informers" kcorev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -14,8 +14,7 @@ import ( "k8s.io/client-go/rest" emeventingv1alpha1 "github.com/kyma-project/eventing-manager/api/eventing/v1alpha1" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/informers" + emeventingv2alpha1 "github.com/kyma-project/eventing-manager/api/eventing/v1alpha2" ) func SubscriptionGVR() schema.GroupVersionResource { diff --git a/pkg/subscribed/processor.go b/pkg/subscribed/processor.go index 7a84975..ca9eefb 100644 --- a/pkg/subscribed/processor.go +++ b/pkg/subscribed/processor.go @@ -3,13 +3,12 @@ package subscribed import ( "net/http" - "github.com/kyma-project/eventing-manager/pkg/logger" + "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" "go.uber.org/zap" - "k8s.io/apimachinery/pkg/labels" "k8s.io/client-go/tools/cache" - "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" + "github.com/kyma-project/eventing-manager/pkg/logger" ) const processorName = "processor" diff --git a/pkg/subscribed/response.go b/pkg/subscribed/response.go index 61e1dcf..f84dfa0 100644 --- a/pkg/subscribed/response.go +++ b/pkg/subscribed/response.go @@ -4,11 +4,11 @@ import ( "encoding/json" "net/http" - "github.com/kyma-project/eventing-manager/pkg/logger" - "go.uber.org/zap" - "github.com/kyma-project/eventing-publisher-proxy/internal" "github.com/kyma-project/eventing-publisher-proxy/pkg/legacy" + "go.uber.org/zap" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) const responseName = "response" diff --git a/pkg/tracing/helpers_test.go b/pkg/tracing/helpers_test.go index aa018e9..8dcad62 100644 --- a/pkg/tracing/helpers_test.go +++ b/pkg/tracing/helpers_test.go @@ -5,7 +5,6 @@ import ( "testing" ceevent "github.com/cloudevents/sdk-go/v2/event" - "github.com/onsi/gomega" ) diff --git a/pkg/tracing/propagation/tracecontextb3/http_format.go b/pkg/tracing/propagation/tracecontextb3/http_format.go index 45cf064..41c98c8 100644 --- a/pkg/tracing/propagation/tracecontextb3/http_format.go +++ b/pkg/tracing/propagation/tracecontextb3/http_format.go @@ -1,11 +1,10 @@ package tracecontextb3 import ( + "github.com/kyma-project/eventing-publisher-proxy/pkg/tracing/propagation" "go.opencensus.io/plugin/ochttp/propagation/b3" "go.opencensus.io/plugin/ochttp/propagation/tracecontext" ocpropagation "go.opencensus.io/trace/propagation" - - "github.com/kyma-project/eventing-publisher-proxy/pkg/tracing/propagation" ) // TraceContextEgress returns a propagation.HTTPFormat that reads both TraceContext and B3 tracing diff --git a/testing/fixtures.go b/testing/fixtures.go index a43f90f..1dc9b7d 100644 --- a/testing/fixtures.go +++ b/testing/fixtures.go @@ -7,9 +7,8 @@ import ( "testing" ceevent "github.com/cloudevents/sdk-go/v2/event" - "github.com/stretchr/testify/assert" - "github.com/kyma-project/eventing-publisher-proxy/internal" + "github.com/stretchr/testify/assert" ) const ( diff --git a/testing/nats.go b/testing/nats.go index 4774881..66cbff9 100644 --- a/testing/nats.go +++ b/testing/nats.go @@ -3,14 +3,12 @@ package testing import ( "time" - "github.com/nats-io/nats.go" - - "github.com/kyma-project/eventing-manager/pkg/logger" - eppnats "github.com/kyma-project/eventing-publisher-proxy/pkg/nats" - "github.com/nats-io/nats-server/v2/server" "github.com/nats-io/nats-server/v2/test" + "github.com/nats-io/nats.go" + + "github.com/kyma-project/eventing-manager/pkg/logger" ) const (