Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lint Fix: gci & tagalign #69

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint-go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions cmd/eventing-publisher-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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() {
Expand Down
3 changes: 1 addition & 2 deletions pkg/application/applicationtest/applicationtest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 2 additions & 4 deletions pkg/application/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 2 additions & 4 deletions pkg/application/fake/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions pkg/application/lister.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/cloudevents/builder/eventmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions pkg/cloudevents/builder/eventmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 2 additions & 3 deletions pkg/cloudevents/builder/generic.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 4 additions & 4 deletions pkg/cloudevents/builder/generic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 2 additions & 1 deletion pkg/cloudevents/builder/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
5 changes: 2 additions & 3 deletions pkg/cloudevents/eventtype/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
7 changes: 3 additions & 4 deletions pkg/cloudevents/eventtype/clean_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions pkg/cloudevents/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion pkg/cloudevents/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
9 changes: 5 additions & 4 deletions pkg/commander/eventmesh/eventmesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down
9 changes: 5 additions & 4 deletions pkg/commander/nats/nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down
18 changes: 9 additions & 9 deletions pkg/env/eventmesh_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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>.<appName>.<event-name>.<version>
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.
Expand Down
18 changes: 9 additions & 9 deletions pkg/env/nats_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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>.<appName>.<event-name>.<version>
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.
Expand Down
17 changes: 7 additions & 10 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading
Loading