Skip to content

Commit

Permalink
Enable gci linter for imports (#736)
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 authored Oct 20, 2024
1 parent 4d0d1cc commit fea66ee
Show file tree
Hide file tree
Showing 25 changed files with 30 additions and 53 deletions.
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ linters:
- fatcontext
- forbidigo
- forcetypeassert
# - funlen - TODO(ben): maybe consider later; needs some refactoring
- gci


# TODO(ben): Enable those linters step by step and fix existing issues.
# - funlen
# - gci
# - ginkgolinter
# - gocheckcompilerdirectives
# - gochecknoglobals
Expand Down
1 change: 0 additions & 1 deletion src/k8s/cmd/k8s/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package k8s

import (
cmdutil "github.com/canonical/k8s/cmd/util"

"github.com/spf13/cobra"
)

Expand Down
7 changes: 3 additions & 4 deletions src/k8s/cmd/k8sd/k8sd_cluster_recover.go
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@ import (
"github.com/canonical/go-dqlite"
"github.com/canonical/go-dqlite/app"
"github.com/canonical/go-dqlite/client"
cmdutil "github.com/canonical/k8s/cmd/util"
"github.com/canonical/k8s/pkg/log"
"github.com/canonical/k8s/pkg/utils"
"github.com/canonical/lxd/shared"
"github.com/canonical/lxd/shared/termios"
"github.com/canonical/microcluster/v3/cluster"
"github.com/canonical/microcluster/v3/microcluster"
"github.com/spf13/cobra"
"golang.org/x/sys/unix"
"gopkg.in/yaml.v2"

cmdutil "github.com/canonical/k8s/cmd/util"
"github.com/canonical/k8s/pkg/log"
"github.com/canonical/k8s/pkg/utils"
)

const preRecoveryMessage = `You should only run this command if:
Expand Down
5 changes: 2 additions & 3 deletions src/k8s/pkg/client/kubernetes/server_groups_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ package kubernetes_test
import (
"testing"

fakediscovery "k8s.io/client-go/discovery/fake"
fakeclientset "k8s.io/client-go/kubernetes/fake"

"github.com/canonical/k8s/pkg/client/kubernetes"
. "github.com/onsi/gomega"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakediscovery "k8s.io/client-go/discovery/fake"
fakeclientset "k8s.io/client-go/kubernetes/fake"
)

func TestListResourcesForGroupVersion(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/controllers/csrsigning/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/k8s/pkg/utils"
"k8s.io/client-go/rest"

"sigs.k8s.io/controller-runtime/pkg/cache"
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/manager"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@ import (
"errors"
"testing"

k8smock "github.com/canonical/k8s/pkg/k8sd/controllers/csrsigning/test"
"github.com/canonical/k8s/pkg/log"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
. "github.com/onsi/gomega"
certv1 "k8s.io/api/certificates/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"

k8smock "github.com/canonical/k8s/pkg/k8sd/controllers/csrsigning/test"
"github.com/canonical/k8s/pkg/log"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
)

func TestAutoApprove(t *testing.T) {
Expand Down
9 changes: 4 additions & 5 deletions src/k8s/pkg/k8sd/controllers/csrsigning/reconcile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"testing"
"time"

k8smock "github.com/canonical/k8s/pkg/k8sd/controllers/csrsigning/test"
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/log"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
. "github.com/onsi/gomega"
certv1 "k8s.io/api/certificates/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -16,11 +20,6 @@ import (
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

k8smock "github.com/canonical/k8s/pkg/k8sd/controllers/csrsigning/test"
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/log"
pkiutil "github.com/canonical/k8s/pkg/utils/pki"
)

func TestCSRNotFound(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/database/cluster_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package database_test
import (
"context"
"database/sql"
"github.com/canonical/k8s/pkg/utils"
"testing"

"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/k8s/pkg/k8sd/types"
"github.com/canonical/k8s/pkg/utils"
. "github.com/onsi/gomega"
)

Expand Down
3 changes: 1 addition & 2 deletions src/k8s/pkg/k8sd/database/feature_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import (
"testing"
"time"

. "github.com/onsi/gomega"

"github.com/canonical/k8s/pkg/k8sd/database"
"github.com/canonical/k8s/pkg/k8sd/features"
"github.com/canonical/k8s/pkg/k8sd/types"
. "github.com/onsi/gomega"
)

func TestFeatureStatus(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions src/k8s/pkg/k8sd/features/calico/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"errors"
"testing"

. "github.com/onsi/gomega"

"github.com/canonical/k8s/pkg/client/helm"
helmmock "github.com/canonical/k8s/pkg/client/helm/mock"
"github.com/canonical/k8s/pkg/k8sd/features/calico"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"
"github.com/canonical/k8s/pkg/utils"
. "github.com/onsi/gomega"
"k8s.io/utils/ptr"
)

Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/calico/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/canonical/k8s/pkg/snap"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/cilium/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/canonical/k8s/pkg/k8sd/features/cilium"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
v1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/cilium/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"github.com/canonical/k8s/pkg/k8sd/features/cilium"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
v1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/cilium/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"github.com/canonical/k8s/pkg/snap"
snapmock "github.com/canonical/k8s/pkg/snap/mock"
"github.com/canonical/k8s/pkg/utils"

. "github.com/onsi/gomega"
"k8s.io/klog/v2"
"k8s.io/klog/v2/ktesting"
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/cilium/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/canonical/k8s/pkg/snap"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/contour/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/canonical/k8s/pkg/k8sd/features/contour"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakediscovery "k8s.io/client-go/discovery/fake"
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/contour/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import (
"github.com/canonical/k8s/pkg/k8sd/features/contour"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
v1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
11 changes: 5 additions & 6 deletions src/k8s/pkg/k8sd/features/coredns/coredns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import (
"strings"
"testing"

. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/utils/ptr"

"github.com/canonical/k8s/pkg/client/helm"
helmmock "github.com/canonical/k8s/pkg/client/helm/mock"
"github.com/canonical/k8s/pkg/client/kubernetes"
"github.com/canonical/k8s/pkg/k8sd/features/coredns"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/utils/ptr"
)

func TestDisabled(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/k8sd/features/coredns/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"

"github.com/canonical/k8s/pkg/snap"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand Down
5 changes: 2 additions & 3 deletions src/k8s/pkg/k8sd/features/localpv/localpv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"errors"
"testing"

. "github.com/onsi/gomega"
"k8s.io/utils/ptr"

"github.com/canonical/k8s/pkg/client/helm"
helmmock "github.com/canonical/k8s/pkg/client/helm/mock"
"github.com/canonical/k8s/pkg/k8sd/features/localpv"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"
. "github.com/onsi/gomega"
"k8s.io/utils/ptr"
)

func TestDisabled(t *testing.T) {
Expand Down
11 changes: 5 additions & 6 deletions src/k8s/pkg/k8sd/features/metallb/loadbalancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@ import (
"errors"
"testing"

. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/utils/ptr"

"github.com/canonical/k8s/pkg/client/helm"
helmmock "github.com/canonical/k8s/pkg/client/helm/mock"
"github.com/canonical/k8s/pkg/client/kubernetes"
"github.com/canonical/k8s/pkg/k8sd/features/metallb"
"github.com/canonical/k8s/pkg/k8sd/types"
snapmock "github.com/canonical/k8s/pkg/snap/mock"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fakediscovery "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/kubernetes/fake"
"k8s.io/utils/ptr"
)

func TestDisabled(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/snap/pebble_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
)

Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/snap/snap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"github.com/canonical/k8s/pkg/snap"
"github.com/canonical/k8s/pkg/snap/mock"

. "github.com/onsi/gomega"
)

Expand Down
1 change: 0 additions & 1 deletion src/k8s/pkg/utils/certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"testing"

"github.com/canonical/k8s/pkg/utils"

. "github.com/onsi/gomega"
)

Expand Down
3 changes: 1 addition & 2 deletions src/k8s/pkg/utils/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import (
"sort"
"strings"

"github.com/moby/sys/mountinfo"

"github.com/canonical/k8s/pkg/log"
"github.com/moby/sys/mountinfo"
)

// ParseArgumentLine parses a command-line argument from a single line.
Expand Down

0 comments on commit fea66ee

Please sign in to comment.