Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,30 @@ linters-settings:
# 2. you use go >= 1.10
# 3. you do repeated runs (false for CI) or cache $GOPATH/pkg or `go env GOCACHE` dir in CI.
use-installed-packages: false
golint:
# minimal confidence for issues, default is 0.8
min-confidence: 0.8
revive:
confidence: 0.8
severity: warning
errorCode: 0
warningCode: 0
rules:
- name: blank-imports
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the golint defaults. They are defined one-by-one for clarity on what's being checked.
I removed dot-import rule. The rest I fixed. If we decide, we can enable some additional rules.

- name: context-as-argument
- name: context-keys-type
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
gofmt:
# simplify code: gofmt with `-s` option, true by default
simplify: false
Expand Down Expand Up @@ -157,7 +178,7 @@ linters:
- errcheck
- gofmt
- goimports
- golint
- revive
- gosimple
- govet
- ineffassign
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package backwards_compat

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package before_active

import (
"fmt"
"testing"

awseks "github.com/aws/aws-sdk-go/service/eks"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

. "github.com/weaveworks/eksctl/integration/matchers"
. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/tests"
"github.com/weaveworks/eksctl/pkg/testutils"

awseks "github.com/aws/aws-sdk-go/service/eks"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)

var params *tests.Params
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package cloudwatch_logging

import (
Expand All @@ -15,6 +16,7 @@ import (
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"

"github.com/pkg/errors"

"github.com/weaveworks/eksctl/pkg/testutils"

. "github.com/weaveworks/eksctl/integration/runner"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package cluster_api

import (
Expand Down
2 changes: 2 additions & 0 deletions integration/tests/cluster_dns/cluster_dns_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package cluster_dns

import (
Expand All @@ -10,6 +11,7 @@ import (

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

. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/utilities/kube"

Expand Down
6 changes: 3 additions & 3 deletions integration/tests/dry_run/dry_run_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package dry_run

import (
Expand All @@ -10,18 +11,17 @@ import (
"testing"

"github.com/aws/aws-sdk-go/aws"
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
. "github.com/weaveworks/eksctl/integration/runner"

. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/tests"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/eks"
"github.com/weaveworks/eksctl/pkg/testutils"
"github.com/weaveworks/eksctl/pkg/utils/ipnet"

. "github.com/onsi/ginkgo"
)

var params *tests.Params
Expand Down
2 changes: 2 additions & 0 deletions integration/tests/eks_connector/eks_connector_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package eks_connector_test

import (
Expand All @@ -14,6 +15,7 @@ import (
awseks "github.com/aws/aws-sdk-go/service/eks"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/tests"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package instance_selector

import (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package quickstart_profiles_gen

import (
Expand Down
21 changes: 9 additions & 12 deletions integration/tests/unowned_cluster/unowned_cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//go:build integration
// +build integration

//revive:disable Not changing package name
package unowned_clusters

import (
Expand All @@ -11,23 +12,19 @@ import (
"testing"
"time"

"github.com/aws/aws-sdk-go/service/kms"
"github.com/weaveworks/eksctl/pkg/eks"

cfn "github.com/aws/aws-sdk-go/service/cloudformation"

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

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"

cfn "github.com/aws/aws-sdk-go/service/cloudformation"
awseks "github.com/aws/aws-sdk-go/service/eks"
. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/tests"
"github.com/weaveworks/eksctl/pkg/testutils"

"github.com/aws/aws-sdk-go/service/kms"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"

. "github.com/weaveworks/eksctl/integration/runner"
"github.com/weaveworks/eksctl/integration/tests"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/eks"
"github.com/weaveworks/eksctl/pkg/testutils"
)

var params *tests.Params
Expand Down
6 changes: 2 additions & 4 deletions pkg/actions/identityproviders/wait.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/eks"

"github.com/weaveworks/eksctl/pkg/utils/waiters"
)

Expand Down Expand Up @@ -38,8 +39,5 @@ func (m *Manager) waitForUpdate(
clusterName,
)

if err := waiters.Wait(clusterName, msg, acceptors, newRequest, timeout, nil); err != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For these and the rest. These are empty ifs. I know that some prefer to return explicitly, but these are empty statements. If they would add logging or at least wrap the error, I would also leave them be. As such, they add fluff and extra code lines for no reason. :)

return err
}
return nil
return waiters.Wait(clusterName, msg, acceptors, newRequest, timeout, nil)
}
12 changes: 2 additions & 10 deletions pkg/actions/nodegroup/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,7 @@ func (m *Manager) nodeCreationTasks(options CreateOpts, nodegroupFilter filter.N
}

taskTree.Append(allNodeGroupTasks)
if err := m.init.DoAllNodegroupStackTasks(taskTree, meta.Region, meta.Name); err != nil {
return err
}

return nil
return m.init.DoAllNodegroupStackTasks(taskTree, meta.Region, meta.Name)
}

func (m *Manager) postNodeCreationTasks(clientSet kubernetes.Interface, options CreateOpts) error {
Expand Down Expand Up @@ -307,9 +303,5 @@ func loadVPCFromConfig(provider api.ClusterProvider, cfg *api.ClusterConfig) err
return err
}

if err := cfg.CanUseForPrivateNodeGroups(); err != nil {
return err
}

return nil
return cfg.CanUseForPrivateNodeGroups()
}
14 changes: 6 additions & 8 deletions pkg/actions/repo/enable.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ import (
portforward "github.com/justinbarrick/go-k8s-portforward"
"github.com/kris-nova/logger"
"github.com/pkg/errors"
api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/git"
"github.com/weaveworks/eksctl/pkg/gitops/deploykey"
"github.com/weaveworks/eksctl/pkg/kubernetes"
apierrs "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubeclient "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/git"
"github.com/weaveworks/eksctl/pkg/gitops/deploykey"
"github.com/weaveworks/eksctl/pkg/kubernetes"
)

const (
Expand Down Expand Up @@ -215,10 +216,7 @@ func (fi *Installer) addFilesToRepo() error {
}

// git push
if err := fi.GitClient.Push(); err != nil {
return err
}
return nil
return fi.GitClient.Push()
}

func (fi *Installer) createFluxNamespaceIfMissing(manifestsMap map[string][]byte) error {
Expand Down
8 changes: 2 additions & 6 deletions pkg/apis/eksctl.io/v1alpha5/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type Addon struct {
// AttachPolicy holds a policy document to attach
// +optional
AttachPolicy InlineDocument `json:"attachPolicy,omitempty"`
// ARN of the permissions boundary to associate
// ARN of the permissions' boundary to associate
// +optional
PermissionsBoundary string `json:"permissionsBoundary,omitempty"`
// WellKnownPolicies for attaching common IAM policies
Expand All @@ -41,11 +41,7 @@ func (a Addon) Validate() error {
return fmt.Errorf("name required")
}

if err := a.checkOnlyOnePolicyProviderIsSet(); err != nil {
return err
}

return nil
return a.checkOnlyOnePolicyProviderIsSet()
}

func (a Addon) checkOnlyOnePolicyProviderIsSet() error {
Expand Down
8 changes: 4 additions & 4 deletions pkg/cfn/builder/managed_nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,17 +262,17 @@ func validateLaunchTemplate(launchTemplateData *ec2.ResponseLaunchTemplateData,

func getAMIType(ng *api.ManagedNodeGroup, instanceType string) string {
amiTypeMapping := map[string]struct {
X86_64 string
X86x64 string
GPU string
ARM string
}{
api.NodeImageFamilyAmazonLinux2: {
X86_64: eks.AMITypesAl2X8664,
X86x64: eks.AMITypesAl2X8664,
GPU: eks.AMITypesAl2X8664Gpu,
ARM: eks.AMITypesAl2Arm64,
},
api.NodeImageFamilyBottlerocket: {
X86_64: eks.AMITypesBottlerocketX8664,
X86x64: eks.AMITypesBottlerocketX8664,
ARM: eks.AMITypesBottlerocketArm64,
},
}
Expand All @@ -288,7 +288,7 @@ func getAMIType(ng *api.ManagedNodeGroup, instanceType string) string {
case instanceutils.IsARMInstanceType(instanceType):
return amiType.ARM
default:
return amiType.X86_64
return amiType.X86x64
}
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/cfn/builder/network_interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func buildNetworkInterfaces(
return errors.Wrapf(err, "couldn't retrieve instance type description for %v", instanceTypes)
}

var numEFAs float64 = math.MaxFloat64
var numEFAs = math.MaxFloat64
for _, it := range info.InstanceTypes {
networkInfo := it.NetworkInfo
numEFAs = math.Min(float64(aws.Int64Value(networkInfo.MaximumNetworkCards)), numEFAs)
Expand Down
6 changes: 2 additions & 4 deletions pkg/ctl/cmdutils/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package cmdutils
import (
"github.com/aws/aws-sdk-go/service/eks"
"github.com/kris-nova/logger"

api "github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
"github.com/weaveworks/eksctl/pkg/cfn/manager"
)
Expand All @@ -21,11 +22,8 @@ func PopulateNodegroup(stackManager manager.StackManager, name string, cfg *api.
}
nodeGroupType = api.NodeGroupTypeUnowned
}
if err = PopulateNodegroupFromStack(nodeGroupType, name, cfg); err != nil {
return err
}

return nil
return PopulateNodegroupFromStack(nodeGroupType, name, cfg)
}

// PopulateNodegroupFromStack populates the nodegroup field of an api.ClusterConfig by type from its CF stack.
Expand Down
Loading