Skip to content

Commit 7b28113

Browse files
authored
make golangci-lint config consistent across repos (#255)
Signed-off-by: Joe Lanford <[email protected]>
1 parent cc1abf4 commit 7b28113

File tree

11 files changed

+215
-29
lines changed

11 files changed

+215
-29
lines changed

.bingo/Variables.mk

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ $(GINKGO): $(BINGO_DIR)/ginkgo.mod
3535
@echo "(re)installing $(GOBIN)/ginkgo-v2.12.0"
3636
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=ginkgo.mod -o=$(GOBIN)/ginkgo-v2.12.0 "github.com/onsi/ginkgo/v2/ginkgo"
3737

38-
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.53.3
38+
GOLANGCI_LINT := $(GOBIN)/golangci-lint-v1.57.2
3939
$(GOLANGCI_LINT): $(BINGO_DIR)/golangci-lint.mod
4040
@# Install binary/ries using Go 1.14+ build command. This is using bwplotka/bingo-controlled, separate go module with pinned dependencies.
41-
@echo "(re)installing $(GOBIN)/golangci-lint-v1.53.3"
42-
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.53.3 "github.com/golangci/golangci-lint/cmd/golangci-lint"
41+
@echo "(re)installing $(GOBIN)/golangci-lint-v1.57.2"
42+
@cd $(BINGO_DIR) && GOWORK=off $(GO) build -mod=mod -modfile=golangci-lint.mod -o=$(GOBIN)/golangci-lint-v1.57.2 "github.com/golangci/golangci-lint/cmd/golangci-lint"
4343

4444
GORELEASER := $(GOBIN)/goreleaser-v1.16.2
4545
$(GORELEASER): $(BINGO_DIR)/goreleaser.mod

.bingo/golangci-lint.mod

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
module _ // Auto generated by https://github.com/bwplotka/bingo. DO NOT EDIT
22

3-
go 1.20
3+
go 1.21
44

5-
require github.com/golangci/golangci-lint v1.53.3 // cmd/golangci-lint
5+
toolchain go1.22.2
6+
7+
require github.com/golangci/golangci-lint v1.57.2 // cmd/golangci-lint

.bingo/golangci-lint.sum

Lines changed: 161 additions & 0 deletions
Large diffs are not rendered by default.

.bingo/variables.env

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ CONTROLLER_GEN="${GOBIN}/controller-gen-v0.12.0"
1414

1515
GINKGO="${GOBIN}/ginkgo-v2.12.0"
1616

17-
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.53.3"
17+
GOLANGCI_LINT="${GOBIN}/golangci-lint-v1.57.2"
1818

1919
GORELEASER="${GOBIN}/goreleaser-v1.16.2"
2020

.golangci.yaml

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
########
2+
# NOTE
3+
#
4+
# This file is duplicated in the following repos:
5+
# - operator-framework/kubectl-operator
6+
# - operator-framework/catalogd
7+
# - operator-framework/operator-controller
8+
# - operator-framework/rukpak
9+
#
10+
# If you are making a change, please make it in ALL
11+
# of the above repositories!
12+
#
13+
# TODO: Find a way to have a shared golangci config.
14+
########
15+
116
run:
217
# Default timeout is 1m, up to give more room
318
timeout: 4m
@@ -7,16 +22,14 @@ linters:
722
- asciicheck
823
- bodyclose
924
- errorlint
10-
- ginkgolinter
25+
- gci
1126
- gofmt
12-
- goimports
1327
- gosec
1428
- importas
1529
- misspell
1630
- nestif
1731
- nonamedreturns
1832
- prealloc
19-
- revive
2033
- stylecheck
2134
- tparallel
2235
- unconvert
@@ -25,6 +38,18 @@ linters:
2538
- whitespace
2639

2740
linters-settings:
41+
gci:
42+
sections:
43+
- standard
44+
- dot
45+
- default
46+
- prefix(github.com/operator-framework)
47+
48+
# TODO: change this to `localmodule` when golangci-lint
49+
# is updated to 1.58+
50+
- prefix(github.com/operator-framework/catalogd)
51+
custom-order: true
52+
2853
errorlint:
2954
errorf: false
3055

@@ -42,10 +67,11 @@ linters-settings:
4267
alias: $1$2
4368
- pkg: sigs.k8s.io/controller-runtime
4469
alias: ctrl
45-
- pkg: github.com/operator-framework/rukpak/api/v1alpha1
46-
alias: rukpakv1alpha1
47-
goimports:
48-
local-prefixes: github.com/operator-framework/catalogd
70+
- pkg: github.com/operator-framework/rukpak/api/v1alpha2
71+
alias: rukpakv1alpha2
72+
- pkg: github.com/blang/semver/v4
73+
alias: bsemver
4974

5075
output:
51-
format: tab
76+
formats:
77+
- format: tab

api/core/v1alpha1/catalog_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestPollIntervalCELValidationRules(t *testing.T) {
5656
},
5757
} {
5858
t.Run(name, func(t *testing.T) {
59-
obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&tc.spec)
59+
obj, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&tc.spec) //nolint:gosec
6060
require.NoError(t, err)
6161
errs := validator(obj, nil)
6262
require.Equal(t, len(tc.wantErrs), len(errs))

cmd/manager/main.go

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,19 @@ import (
2525
"path/filepath"
2626
"time"
2727

28-
// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
29-
// to ensure that exec-entrypoint and run can make use of them.
30-
"k8s.io/client-go/metadata"
31-
_ "k8s.io/client-go/plugin/pkg/client/auth"
32-
28+
"github.com/spf13/pflag"
3329
"k8s.io/apimachinery/pkg/runtime"
3430
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3531
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
32+
"k8s.io/client-go/metadata"
33+
_ "k8s.io/client-go/plugin/pkg/client/auth"
3634
ctrl "sigs.k8s.io/controller-runtime"
3735
"sigs.k8s.io/controller-runtime/pkg/healthz"
3836
"sigs.k8s.io/controller-runtime/pkg/log/zap"
3937
"sigs.k8s.io/controller-runtime/pkg/metrics"
4038
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
4139

42-
"github.com/spf13/pflag"
43-
40+
"github.com/operator-framework/catalogd/api/core/v1alpha1"
4441
"github.com/operator-framework/catalogd/internal/garbagecollection"
4542
"github.com/operator-framework/catalogd/internal/source"
4643
"github.com/operator-framework/catalogd/internal/third_party/server"
@@ -49,9 +46,6 @@ import (
4946
"github.com/operator-framework/catalogd/pkg/features"
5047
catalogdmetrics "github.com/operator-framework/catalogd/pkg/metrics"
5148
"github.com/operator-framework/catalogd/pkg/storage"
52-
53-
//+kubebuilder:scaffold:imports
54-
"github.com/operator-framework/catalogd/api/core/v1alpha1"
5549
)
5650

5751
var (

pkg/controllers/core/catalog_controller_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ import (
1010
"time"
1111

1212
"github.com/google/go-cmp/cmp"
13+
"github.com/google/go-cmp/cmp/cmpopts"
1314
"github.com/stretchr/testify/assert"
1415
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1516
ctrl "sigs.k8s.io/controller-runtime"
1617

17-
"github.com/google/go-cmp/cmp/cmpopts"
18-
1918
catalogdv1alpha1 "github.com/operator-framework/catalogd/api/core/v1alpha1"
2019
"github.com/operator-framework/catalogd/internal/source"
2120
"github.com/operator-framework/catalogd/pkg/storage"

pkg/storage/localdir_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import (
1212
"path/filepath"
1313
"testing/fstest"
1414

15-
"github.com/google/go-cmp/cmp"
1615
. "github.com/onsi/ginkgo/v2"
1716
. "github.com/onsi/gomega"
17+
18+
"github.com/google/go-cmp/cmp"
19+
1820
"github.com/operator-framework/operator-registry/alpha/declcfg"
1921
)
2022

test/e2e/e2e_suite_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
9+
910
"k8s.io/client-go/kubernetes"
1011
"k8s.io/client-go/kubernetes/scheme"
1112
"k8s.io/client-go/rest"

test/e2e/unpack_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ import (
77
"os"
88
"strings"
99

10-
"github.com/google/go-cmp/cmp"
1110
. "github.com/onsi/ginkgo/v2"
1211
. "github.com/onsi/gomega"
12+
13+
"github.com/google/go-cmp/cmp"
1314
"k8s.io/apimachinery/pkg/api/errors"
1415
"k8s.io/apimachinery/pkg/api/meta"
1516
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

0 commit comments

Comments
 (0)