Skip to content

Commit ccf0856

Browse files
Merge pull request openshift-kni#1527 from openshift-kni/linter-import-order
lint: add gci linter to enforce import ordering
2 parents aad063f + cf40f31 commit ccf0856

File tree

121 files changed

+387
-331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+387
-331
lines changed

.golangci.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ issues:
1616
exclude-rules:
1717
- path: "api/*"
1818
linters:
19+
- gci
1920
- lll
21+
- path: "cmd/*"
22+
linters:
23+
- gci
2024
- path: "internal/*"
2125
linters:
2226
- dupl
@@ -36,6 +40,7 @@ linters:
3640
- bodyclose
3741
- copyloopvar
3842
- depguard
43+
- gci
3944
- ginkgolinter
4045
- gosimple
4146
- govet
@@ -53,6 +58,18 @@ linters:
5358
- gocritic
5459
- stylecheck
5560
linters-settings:
61+
gci:
62+
sections:
63+
- standard
64+
- blank
65+
- default
66+
- prefix(k8s.io)
67+
- prefix(sigs.k8s.io)
68+
- prefix(github.com/openshift)
69+
- prefix(github.com/k8stopologyawareschedwg)
70+
- prefix(github.com/openshift-kni)
71+
- dot
72+
custom-order: true
5673
revive:
5774
rules:
5875
- name: comment-spacings

internal/api/features/topics.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@
1717
package features
1818

1919
import (
20-
_ "embed"
2120
"encoding/json"
21+
22+
_ "embed"
2223
)
2324

2425
//go:embed _topics.json

internal/baseload/baseload.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"context"
2121
"fmt"
2222

23-
"sigs.k8s.io/controller-runtime/pkg/client"
24-
2523
corev1 "k8s.io/api/core/v1"
2624
"k8s.io/apimachinery/pkg/api/resource"
2725

26+
"sigs.k8s.io/controller-runtime/pkg/client"
27+
2828
"github.com/openshift-kni/numaresources-operator/internal/podlist"
2929
"github.com/openshift-kni/numaresources-operator/internal/resourcelist"
3030
)

internal/controller/kubeletconfig_controller.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23-
"k8s.io/apimachinery/pkg/api/equality"
2423
"slices"
2524
"time"
2625

2726
corev1 "k8s.io/api/core/v1"
27+
"k8s.io/apimachinery/pkg/api/equality"
2828
apierrors "k8s.io/apimachinery/pkg/api/errors"
2929
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3030
"k8s.io/apimachinery/pkg/labels"
@@ -33,6 +33,7 @@ import (
3333
"k8s.io/client-go/tools/record"
3434
"k8s.io/klog/v2"
3535
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
36+
3637
ctrl "sigs.k8s.io/controller-runtime"
3738
"sigs.k8s.io/controller-runtime/pkg/builder"
3839
"sigs.k8s.io/controller-runtime/pkg/client"
@@ -45,6 +46,7 @@ import (
4546
mcov1 "github.com/openshift/api/machineconfiguration/v1"
4647

4748
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
49+
4850
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
4951
"github.com/openshift-kni/numaresources-operator/internal/machineconfigpools"
5052
"github.com/openshift-kni/numaresources-operator/pkg/apply"

internal/controller/kubeletconfig_controller_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,27 +19,28 @@ package controller
1919
import (
2020
"context"
2121

22-
. "github.com/onsi/ginkgo/v2"
23-
. "github.com/onsi/gomega"
24-
2522
corev1 "k8s.io/api/core/v1"
2623
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2724
"k8s.io/apimachinery/pkg/runtime"
2825
"k8s.io/client-go/kubernetes/scheme"
2926
"k8s.io/client-go/tools/record"
3027
kubeletconfigv1beta1 "k8s.io/kubelet/config/v1beta1"
28+
3129
"sigs.k8s.io/controller-runtime/pkg/client"
3230
"sigs.k8s.io/controller-runtime/pkg/client/fake"
3331
"sigs.k8s.io/controller-runtime/pkg/reconcile"
3432

3533
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
3634

3735
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
36+
3837
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
38+
testobjs "github.com/openshift-kni/numaresources-operator/internal/objects"
3939
"github.com/openshift-kni/numaresources-operator/pkg/objectnames"
4040
rteconfig "github.com/openshift-kni/numaresources-operator/rte/pkg/config"
4141

42-
testobjs "github.com/openshift-kni/numaresources-operator/internal/objects"
42+
. "github.com/onsi/ginkgo/v2"
43+
. "github.com/onsi/gomega"
4344
)
4445

4546
type reconcilerBuilderFunc func(...runtime.Object) (*KubeletConfigReconciler, error)

internal/controller/numaresourcesoperator_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ import (
5050
"github.com/k8stopologyawareschedwg/deployer/pkg/manifests"
5151
apimanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/api"
5252
k8swgrteupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate/rte"
53+
5354
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
5455
"github.com/openshift-kni/numaresources-operator/api/v1/helper/namespacedname"
5556
nodegroupv1 "github.com/openshift-kni/numaresources-operator/api/v1/helper/nodegroup"
5657
"github.com/openshift-kni/numaresources-operator/internal/api/annotations"
5758
"github.com/openshift-kni/numaresources-operator/internal/dangling"
59+
intreconcile "github.com/openshift-kni/numaresources-operator/internal/reconcile"
5860
"github.com/openshift-kni/numaresources-operator/internal/relatedobjects"
5961
"github.com/openshift-kni/numaresources-operator/pkg/apply"
6062
"github.com/openshift-kni/numaresources-operator/pkg/images"
@@ -67,8 +69,6 @@ import (
6769
"github.com/openshift-kni/numaresources-operator/pkg/status/conditioninfo"
6870
"github.com/openshift-kni/numaresources-operator/pkg/validation"
6971
"github.com/openshift-kni/numaresources-operator/rte/pkg/config"
70-
71-
intreconcile "github.com/openshift-kni/numaresources-operator/internal/reconcile"
7272
)
7373

7474
const numaResourcesRetryPeriod = 1 * time.Minute

internal/controller/numaresourcesoperator_controller_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import (
2222
"fmt"
2323
"time"
2424

25-
. "github.com/onsi/ginkgo/v2"
26-
. "github.com/onsi/gomega"
25+
igntypes "github.com/coreos/ignition/v2/config/v3_2/types"
2726
"github.com/onsi/gomega/gcustom"
2827
gomegatypes "github.com/onsi/gomega/types"
2928

@@ -36,20 +35,19 @@ import (
3635
"k8s.io/apimachinery/pkg/runtime"
3736
"k8s.io/client-go/kubernetes/scheme"
3837
"k8s.io/client-go/tools/record"
38+
3939
"sigs.k8s.io/controller-runtime/pkg/client"
4040
"sigs.k8s.io/controller-runtime/pkg/client/fake"
4141
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4242

43-
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
44-
apimanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/api"
45-
rtemanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/rte"
46-
47-
igntypes "github.com/coreos/ignition/v2/config/v3_2/types"
48-
4943
configv1 "github.com/openshift/api/config/v1"
5044
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
5145
securityv1 "github.com/openshift/api/security/v1"
5246

47+
"github.com/k8stopologyawareschedwg/deployer/pkg/deployer/platform"
48+
apimanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/api"
49+
rtemanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests/rte"
50+
5351
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
5452
"github.com/openshift-kni/numaresources-operator/internal/api/annotations"
5553
inthelper "github.com/openshift-kni/numaresources-operator/internal/api/annotations/helper"
@@ -61,6 +59,9 @@ import (
6159
"github.com/openshift-kni/numaresources-operator/pkg/objectstate/rte"
6260
"github.com/openshift-kni/numaresources-operator/pkg/status"
6361
"github.com/openshift-kni/numaresources-operator/pkg/validation"
62+
63+
. "github.com/onsi/ginkgo/v2"
64+
. "github.com/onsi/gomega"
6465
)
6566

6667
const (

internal/controller/numaresourcesscheduler_controller.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ import (
2121
"fmt"
2222
"time"
2323

24-
"sigs.k8s.io/controller-runtime/pkg/handler"
25-
2624
appsv1 "k8s.io/api/apps/v1"
2725
corev1 "k8s.io/api/core/v1"
2826
rbacv1 "k8s.io/api/rbac/v1"
@@ -33,11 +31,13 @@ import (
3331
"k8s.io/apimachinery/pkg/runtime"
3432
"k8s.io/klog/v2"
3533
"k8s.io/utils/ptr"
34+
3635
ctrl "sigs.k8s.io/controller-runtime"
3736
"sigs.k8s.io/controller-runtime/pkg/builder"
3837
"sigs.k8s.io/controller-runtime/pkg/client"
3938
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
4039
"sigs.k8s.io/controller-runtime/pkg/event"
40+
"sigs.k8s.io/controller-runtime/pkg/handler"
4141
"sigs.k8s.io/controller-runtime/pkg/predicate"
4242
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4343

internal/controller/numaresourcesscheduler_controller_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ import (
2121
"fmt"
2222
"time"
2323

24+
"github.com/google/go-cmp/cmp"
2425
"github.com/onsi/ginkgo/v2"
2526
"github.com/onsi/gomega"
26-
configv1 "github.com/openshift/api/config/v1"
27-
28-
"github.com/google/go-cmp/cmp"
2927

3028
appsv1 "k8s.io/api/apps/v1"
3129
corev1 "k8s.io/api/core/v1"
@@ -35,21 +33,24 @@ import (
3533
"k8s.io/client-go/kubernetes/scheme"
3634
"k8s.io/klog/v2"
3735
"k8s.io/utils/ptr"
36+
3837
"sigs.k8s.io/controller-runtime/pkg/client"
3938
"sigs.k8s.io/controller-runtime/pkg/client/fake"
4039
"sigs.k8s.io/controller-runtime/pkg/reconcile"
4140

41+
configv1 "github.com/openshift/api/config/v1"
42+
4243
depmanifests "github.com/k8stopologyawareschedwg/deployer/pkg/manifests"
4344
depobjupdate "github.com/k8stopologyawareschedwg/deployer/pkg/objectupdate"
45+
4446
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
47+
testobjs "github.com/openshift-kni/numaresources-operator/internal/objects"
4548
"github.com/openshift-kni/numaresources-operator/pkg/hash"
4649
nrosched "github.com/openshift-kni/numaresources-operator/pkg/numaresourcesscheduler"
4750
schedmanifests "github.com/openshift-kni/numaresources-operator/pkg/numaresourcesscheduler/manifests/sched"
4851
"github.com/openshift-kni/numaresources-operator/pkg/numaresourcesscheduler/objectstate/sched"
4952
schedupdate "github.com/openshift-kni/numaresources-operator/pkg/objectupdate/sched"
5053
"github.com/openshift-kni/numaresources-operator/pkg/status"
51-
52-
testobjs "github.com/openshift-kni/numaresources-operator/internal/objects"
5354
)
5455

5556
const testSchedulerName = "testSchedulerName"

internal/controller/suite_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,20 @@ import (
2020
"path/filepath"
2121
"testing"
2222

23-
. "github.com/onsi/ginkgo/v2"
24-
. "github.com/onsi/gomega"
25-
26-
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
27-
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
28-
securityv1 "github.com/openshift/api/security/v1"
2923
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
3024
"k8s.io/client-go/kubernetes/scheme"
3125
"k8s.io/client-go/rest"
26+
3227
"sigs.k8s.io/controller-runtime/pkg/client"
3328
"sigs.k8s.io/controller-runtime/pkg/envtest"
34-
//+kubebuilder:scaffold:imports
29+
30+
machineconfigv1 "github.com/openshift/api/machineconfiguration/v1"
31+
securityv1 "github.com/openshift/api/security/v1"
32+
33+
nropv1 "github.com/openshift-kni/numaresources-operator/api/v1"
34+
35+
. "github.com/onsi/ginkgo/v2"
36+
. "github.com/onsi/gomega"
3537
)
3638

3739
const testNamespace = "test-namespace"

0 commit comments

Comments
 (0)