Skip to content

Commit

Permalink
Enable gci golinter
Browse files Browse the repository at this point in the history
gci linter controls golang package import order and make it always deterministic.

Imports will be now grouped in three parts.
- Go standard packages
- Other packages
- Packages with prefix of `sigs.k8s.io/cluster-api`
  • Loading branch information
Winnie Kwon committed Jan 19, 2022
1 parent 385bb82 commit e07d4fd
Show file tree
Hide file tree
Showing 245 changed files with 457 additions and 376 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ linters:
- dogsled
- errcheck
- exportloopref
- gci
- goconst
- gocritic
- gocyclo
Expand Down Expand Up @@ -51,6 +52,8 @@ linters-settings:
ifshort:
# Maximum length of variable declaration measured in number of characters, after which linter won't suggest using short syntax.
max-decl-chars: 50
gci:
local-prefixes: "sigs.k8s.io/cluster-api"
importas:
no-unaliased: false
alias:
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/awscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/awsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
"sigs.k8s.io/cluster-api/errors"
)
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"reflect"

"k8s.io/apimachinery/pkg/types"

clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"k8s.io/apimachinery/pkg/util/sets"

clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

Expand Down
7 changes: 3 additions & 4 deletions api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ import (
"path"
"testing"

infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"

// +kubebuilder:scaffold:imports
infrav1 "sigs.k8s.io/cluster-api-provider-aws/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
)

// These tests use Ginkgo (BDD-style Go testing framework). Refer to
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha3/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"testing"

. "github.com/onsi/gomega"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/controller-runtime/pkg/client"

"sigs.k8s.io/cluster-api/util"
)

func TestAWSClusterConversion(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/awscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/awsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
"sigs.k8s.io/cluster-api/errors"
)
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha4 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"reflect"

"k8s.io/apimachinery/pkg/types"

clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha4/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"time"

"k8s.io/apimachinery/pkg/util/sets"

clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/awscluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
5 changes: 3 additions & 2 deletions api/v1beta1/awscluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/annotations"
ctrl "sigs.k8s.io/controller-runtime"
logf "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/webhook"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util/annotations"
)

// log is for logging in this package.
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/awscluster_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ import (

"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/gomega"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
utildefaulting "sigs.k8s.io/cluster-api/util/defaulting"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func TestAWSClusterDefault(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/awsclustercontrolleridentity_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"

. "github.com/onsi/gomega"

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

clusterv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/awsclusterroleidentity_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"

. "github.com/onsi/gomega"

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

clusterv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
)

Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/awsclusterstaticidentity_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import (
"testing"

. "github.com/onsi/gomega"

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

clusterv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/awsclustertemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/awsmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/awsmachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import (
"context"
"testing"

. "github.com/onsi/gomega"

"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"

utildefaulting "sigs.k8s.io/cluster-api/util/defaulting"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/awsmachinetemplate_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
)

Expand Down
4 changes: 1 addition & 3 deletions api/v1beta1/sshkeyname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ import (
"context"
"testing"

"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/aws/aws-sdk-go/aws"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func Test_SSHKeyName(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta1/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ import (

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"

"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
)

var (
Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"reflect"

"k8s.io/apimachinery/pkg/types"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
"k8s.io/apimachinery/pkg/util/sets"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
1 change: 1 addition & 0 deletions bootstrap/eks/api/v1alpha3/eksconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha3

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha3 "sigs.k8s.io/cluster-api/api/v1alpha3"
)

Expand Down
5 changes: 3 additions & 2 deletions bootstrap/eks/api/v1alpha3/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
ctrl "sigs.k8s.io/controller-runtime"

// +kubebuilder:scaffold:imports
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion bootstrap/eks/api/v1alpha3/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ import (

. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/controller-runtime/pkg/client"

"sigs.k8s.io/cluster-api/util"
)

func TestEKSConfigConversion(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions bootstrap/eks/api/v1alpha4/eksconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1alpha4

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1alpha4 "sigs.k8s.io/cluster-api/api/v1alpha4"
)

Expand Down
5 changes: 3 additions & 2 deletions bootstrap/eks/api/v1alpha4/webhook_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
ctrl "sigs.k8s.io/controller-runtime"

// +kubebuilder:scaffold:imports
eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/test/helpers"
)

var (
Expand Down
1 change: 1 addition & 0 deletions bootstrap/eks/api/v1beta1/eksconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package v1beta1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

Expand Down
17 changes: 8 additions & 9 deletions bootstrap/eks/controllers/eksconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/utils/pointer"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"

eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/internal/userdata"
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
bsutil "sigs.k8s.io/cluster-api/bootstrap/util"
expclusterv1 "sigs.k8s.io/cluster-api/exp/api/v1beta1"
Expand All @@ -37,15 +45,6 @@ import (
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/cluster-api/util/patch"
"sigs.k8s.io/cluster-api/util/predicates"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/source"

eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/internal/userdata"
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1"
)

// EKSConfigReconciler reconciles a EKSConfig object.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ import (
"testing"

. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"

eksbootstrapv1 "sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/api/v1beta1"
"sigs.k8s.io/cluster-api-provider-aws/bootstrap/eks/internal/userdata"
ekscontrolplanev1 "sigs.k8s.io/cluster-api-provider-aws/controlplane/eks/api/v1beta1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/util"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/yaml"
)

func TestEKSConfigReconciler(t *testing.T) {
Expand Down
Loading

0 comments on commit e07d4fd

Please sign in to comment.