Skip to content

Commit

Permalink
chore: linters and central linter configuraton (#344)
Browse files Browse the repository at this point in the history
* Linter: bodyclose

* Linter: gci

* Linter: funlen

* Remove TODO: delete the following logic after migrating to modular Kyma

* Linter: dupword

* Linter: thelper

* Linter: tagalign

* Linter: perfsprint

* Linter: gomoddirectives

* Central Linter Config

* No lint for dupword

* go-version: "1.22"
  • Loading branch information
the1bit authored Mar 1, 2024
1 parent 5e03864 commit 84519d3
Show file tree
Hide file tree
Showing 26 changed files with 121 additions and 378 deletions.
21 changes: 6 additions & 15 deletions .github/workflows/codequality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,9 @@ permissions:
pull-requests: read

jobs:
lint:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.21"
cache: false
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
# Optional: version of golangci-lint to use in form of v1.2 or v1.2.3 or `latest` to use the latest version
version: v1.55
args: --timeout=5m
code-linter:
name: "Run golangci-lint"
uses: kyma-project/eventing-tools/.github/workflows/lint-go-reusable.yml@main
with:
go-version: "1.22"
lint-config-uri: https://raw.githubusercontent.com/kyma-project/eventing-tools/abb93fa301d4b1aa07b46e5b01ffb0463f06e1bb/config/lint/.golangci.yaml
242 changes: 0 additions & 242 deletions .golangci.yaml

This file was deleted.

21 changes: 10 additions & 11 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ import (
"flag"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
nmctrlcache "github.com/kyma-project/nats-manager/internal/controller/cache"
nmctrl "github.com/kyma-project/nats-manager/internal/controller/nats"
"github.com/kyma-project/nats-manager/pkg/env"
"github.com/kyma-project/nats-manager/pkg/k8s"
"github.com/kyma-project/nats-manager/pkg/k8s/chart"
nmmgr "github.com/kyma-project/nats-manager/pkg/manager"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
kapiextclientset "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
Expand All @@ -37,13 +40,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
nmctrlcache "github.com/kyma-project/nats-manager/internal/controller/cache"
nmctrl "github.com/kyma-project/nats-manager/internal/controller/nats"
"github.com/kyma-project/nats-manager/pkg/env"
"github.com/kyma-project/nats-manager/pkg/k8s"
"github.com/kyma-project/nats-manager/pkg/k8s/chart"
nmmgr "github.com/kyma-project/nats-manager/pkg/manager"
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
)

const defaultMetricsPort = 9443
Expand Down
5 changes: 2 additions & 3 deletions e2e/common/fixtures/fixtures.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package fixtures

import (
nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/testutils"
kcorev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
kmetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/testutils"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions e2e/common/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import (
"os"
"path/filepath"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"k8s.io/client-go/kubernetes"
kscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/client"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
)

func GetK8sClients() (*kubernetes.Clientset, client.Client, error) {
Expand Down
3 changes: 1 addition & 2 deletions internal/controller/cache/cache.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cache

import (
nmlabels "github.com/kyma-project/nats-manager/pkg/labels"
kappsv1 "k8s.io/api/apps/v1"
kautoscalingv1 "k8s.io/api/autoscaling/v1"
kcorev1 "k8s.io/api/core/v1"
Expand All @@ -10,8 +11,6 @@ import (
"k8s.io/client-go/rest"
"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"

nmlabels "github.com/kyma-project/nats-manager/pkg/labels"
)

// New returns a cache with the cache-options applied, generade form the rest-config.
Expand Down
10 changes: 4 additions & 6 deletions internal/controller/nats/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,12 @@ import (
"context"
"fmt"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/pkg/events"
"github.com/kyma-project/nats-manager/pkg/k8s"
"github.com/kyma-project/nats-manager/pkg/k8s/chart"
nmmgr "github.com/kyma-project/nats-manager/pkg/manager"
nmnats "github.com/kyma-project/nats-manager/pkg/nats"

"go.uber.org/zap"
kappsv1 "k8s.io/api/apps/v1"
kcorev1 "k8s.io/api/core/v1"
Expand All @@ -34,11 +37,6 @@ import (
kcontrollerruntime "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"

nmapiv1alpha1 "github.com/kyma-project/nats-manager/api/v1alpha1"
"github.com/kyma-project/nats-manager/pkg/k8s"
"github.com/kyma-project/nats-manager/pkg/k8s/chart"
nmmgr "github.com/kyma-project/nats-manager/pkg/manager"
)

const (
Expand Down
Loading

0 comments on commit 84519d3

Please sign in to comment.