Skip to content

Commit f48ee3c

Browse files
committed
Enable the golangci-lint "import" preset
Most of our files are close to this convention already. The errors reported by "gci" have improved enough to be useful and it can fix typos automatically.
1 parent 46ee186 commit f48ee3c

File tree

17 files changed

+20
-40
lines changed

17 files changed

+20
-40
lines changed

.golangci.yaml

+7-6
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@
33
linters:
44
disable:
55
- contextcheck
6-
- gci
76
- gofumpt
87
enable:
9-
- depguard
108
- goheader
11-
- gomodguard
129
- gosimple
1310
- importas
1411
- misspell
1512
- unconvert
1613
presets:
1714
- bugs
1815
- format
16+
- import
1917
- unused
2018

2119
linters-settings:
@@ -61,6 +59,12 @@ linters-settings:
6159
exhaustive:
6260
default-signifies-exhaustive: true
6361

62+
gci:
63+
sections:
64+
- standard
65+
- default
66+
- localmodule
67+
6468
goheader:
6569
template: |-
6670
Copyright {{ DATES }} Crunchy Data Solutions, Inc.
@@ -70,9 +74,6 @@ linters-settings:
7074
regexp:
7175
DATES: '((201[7-9]|202[0-4]) - 2025|2025)'
7276

73-
goimports:
74-
local-prefixes: github.com/crunchydata/postgres-operator
75-
7677
gomodguard:
7778
blocked:
7879
modules:

internal/bridge/crunchybridgecluster/mock_bridge_api.go

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313

1414
"github.com/crunchydata/postgres-operator/internal/bridge"
1515
"github.com/crunchydata/postgres-operator/internal/initialize"
16-
1716
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
1817
)
1918

internal/bridge/crunchybridgecluster/postgres.go

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/pkg/errors"
1212
corev1 "k8s.io/api/core/v1"
1313
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14-
1514
ctrl "sigs.k8s.io/controller-runtime"
1615
"sigs.k8s.io/controller-runtime/pkg/client"
1716

internal/bridge/crunchybridgecluster/postgres_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ import (
88
"context"
99
"testing"
1010

11-
"sigs.k8s.io/controller-runtime/pkg/client"
12-
1311
"gotest.tools/v3/assert"
1412
corev1 "k8s.io/api/core/v1"
1513
apierrors "k8s.io/apimachinery/pkg/api/errors"
1614
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15+
"sigs.k8s.io/controller-runtime/pkg/client"
1716

1817
"github.com/crunchydata/postgres-operator/internal/bridge"
1918
"github.com/crunchydata/postgres-operator/internal/testing/require"

internal/controller/postgrescluster/controller_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import (
1414
. "github.com/onsi/gomega"
1515
. "github.com/onsi/gomega/gstruct"
1616
"github.com/pkg/errors" //nolint:depguard // This legacy test covers so much code, it logs the origin of unexpected errors.
17-
1817
"gotest.tools/v3/assert"
1918
appsv1 "k8s.io/api/apps/v1"
2019
corev1 "k8s.io/api/core/v1"

internal/controller/postgrescluster/snapshots.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,14 @@ import (
1010
"strings"
1111
"time"
1212

13+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
1314
"github.com/pkg/errors"
1415
batchv1 "k8s.io/api/batch/v1"
1516
corev1 "k8s.io/api/core/v1"
1617
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1718
"k8s.io/apimachinery/pkg/labels"
1819
"sigs.k8s.io/controller-runtime/pkg/client"
1920

20-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
21-
2221
"github.com/crunchydata/postgres-operator/internal/config"
2322
"github.com/crunchydata/postgres-operator/internal/feature"
2423
"github.com/crunchydata/postgres-operator/internal/initialize"

internal/controller/postgrescluster/snapshots_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"testing"
1010
"time"
1111

12+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
1213
"gotest.tools/v3/assert"
1314
appsv1 "k8s.io/api/apps/v1"
1415
batchv1 "k8s.io/api/batch/v1"
@@ -27,8 +28,6 @@ import (
2728
"github.com/crunchydata/postgres-operator/internal/testing/events"
2829
"github.com/crunchydata/postgres-operator/internal/testing/require"
2930
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
30-
31-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
3231
)
3332

3433
func TestReconcileVolumeSnapshots(t *testing.T) {

internal/controller/postgrescluster/suite_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ import (
1414
. "github.com/onsi/gomega"
1515
"k8s.io/apimachinery/pkg/util/version"
1616
"k8s.io/client-go/discovery"
17-
18-
// Google Kubernetes Engine / Google Cloud Platform authentication provider
19-
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
2017
"k8s.io/client-go/rest"
2118
"sigs.k8s.io/controller-runtime/pkg/client"
2219
"sigs.k8s.io/controller-runtime/pkg/log"

internal/controller/runtime/runtime.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package runtime
66

77
import (
8+
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
89
"k8s.io/apimachinery/pkg/runtime"
910
"k8s.io/client-go/kubernetes/scheme"
1011
"k8s.io/client-go/rest"
@@ -15,8 +16,6 @@ import (
1516

1617
"github.com/crunchydata/postgres-operator/internal/logging"
1718
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
18-
19-
volumesnapshotv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
2019
)
2120

2221
type (

internal/controller/standalone_pgadmin/configmap.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ import (
1414
"strconv"
1515
"strings"
1616

17-
corev1 "k8s.io/api/core/v1"
18-
1917
"github.com/pkg/errors"
18+
corev1 "k8s.io/api/core/v1"
2019

2120
"github.com/crunchydata/postgres-operator/internal/collector"
2221
"github.com/crunchydata/postgres-operator/internal/initialize"

internal/controller/standalone_pgadmin/related.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ package standalone_pgadmin
77
import (
88
"context"
99

10+
"k8s.io/apimachinery/pkg/labels"
11+
"sigs.k8s.io/controller-runtime/pkg/client"
12+
1013
"github.com/crunchydata/postgres-operator/internal/initialize"
1114
"github.com/crunchydata/postgres-operator/internal/naming"
1215
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
13-
14-
"k8s.io/apimachinery/pkg/labels"
15-
"sigs.k8s.io/controller-runtime/pkg/client"
1616
)
1717

1818
//+kubebuilder:rbac:groups="postgres-operator.crunchydata.com",resources="pgadmins",verbs={list}

internal/controller/standalone_pgadmin/service.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,14 @@ package standalone_pgadmin
77
import (
88
"context"
99

10+
"github.com/pkg/errors"
1011
corev1 "k8s.io/api/core/v1"
12+
apierrors "k8s.io/apimachinery/pkg/api/errors"
1113
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1214
"k8s.io/apimachinery/pkg/types"
1315
"k8s.io/apimachinery/pkg/util/intstr"
1416
"sigs.k8s.io/controller-runtime/pkg/client"
1517

16-
apierrors "k8s.io/apimachinery/pkg/api/errors"
17-
18-
"github.com/pkg/errors"
19-
2018
"github.com/crunchydata/postgres-operator/internal/logging"
2119
"github.com/crunchydata/postgres-operator/internal/naming"
2220
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"

internal/controller/standalone_pgadmin/statefulset.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ package standalone_pgadmin
77
import (
88
"context"
99

10+
"github.com/pkg/errors"
1011
appsv1 "k8s.io/api/apps/v1"
1112
corev1 "k8s.io/api/core/v1"
1213
apierrors "k8s.io/apimachinery/pkg/api/errors"
1314
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"sigs.k8s.io/controller-runtime/pkg/client"
1516

16-
"github.com/pkg/errors"
17-
1817
"github.com/crunchydata/postgres-operator/internal/collector"
1918
"github.com/crunchydata/postgres-operator/internal/controller/postgrescluster"
2019
"github.com/crunchydata/postgres-operator/internal/initialize"

internal/controller/standalone_pgadmin/volume.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ package standalone_pgadmin
77
import (
88
"context"
99

10+
"github.com/pkg/errors"
1011
corev1 "k8s.io/api/core/v1"
1112
apierrors "k8s.io/apimachinery/pkg/api/errors"
1213
"k8s.io/apimachinery/pkg/api/meta"
1314
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1415
"k8s.io/apimachinery/pkg/util/validation/field"
1516

16-
"github.com/pkg/errors"
17-
1817
"github.com/crunchydata/postgres-operator/internal/naming"
1918
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2019
)

internal/pgbackrest/pgbackrest_test.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@ import (
1313
"testing"
1414

1515
"gotest.tools/v3/assert"
16-
"k8s.io/apimachinery/pkg/api/resource"
17-
1816
corev1 "k8s.io/api/core/v1"
17+
"k8s.io/apimachinery/pkg/api/resource"
1918

2019
"github.com/crunchydata/postgres-operator/internal/testing/require"
21-
2220
"github.com/crunchydata/postgres-operator/pkg/apis/postgres-operator.crunchydata.com/v1beta1"
2321
)
2422

internal/postgres/password/md5.go

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
package password
66

77
import (
8-
98
// #nosec G501
109
"crypto/md5"
1110
"errors"

internal/upgradecheck/header_test.go

-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@ import (
1515
corev1 "k8s.io/api/core/v1"
1616
"k8s.io/apimachinery/pkg/util/uuid"
1717

18-
// Google Kubernetes Engine / Google Cloud Platform authentication provider
19-
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
20-
2118
"github.com/crunchydata/postgres-operator/internal/feature"
2219
"github.com/crunchydata/postgres-operator/internal/kubernetes"
2320
"github.com/crunchydata/postgres-operator/internal/naming"

0 commit comments

Comments
 (0)