Skip to content

Commit

Permalink
Merge pull request #857 from mateimicu/fix-linting
Browse files Browse the repository at this point in the history
fix: linting
  • Loading branch information
mateimicu committed Sep 24, 2023
2 parents cd28b47 + d121bcc commit 6b78e1c
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 17 deletions.
23 changes: 19 additions & 4 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
# - depguard
- dogsled
- dupl
- errcheck
Expand All @@ -29,17 +28,33 @@ linters:
- revive
- rowserrcheck
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace
issues:
exclude:
- Using the variable on range scope .* in function literal
# depguard:
# rules:
# Main:
# files:
# - "$all"
# # List of allowed packages.
# allow:
# - $gostd
# - github.com/OpenPeeDeeP
# - github.com/Masterminds/semver
# - github.com/aws
# - github.com/jedib0t
# - github.com/mateimicu
# - github.com/spf13
# - github.com/stretchr - k8s.io
# # Packages that are not allowed where the value is a suggestion.
# deny:


linters-settings:
errcheck:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# kdiscover
![CI](https://github.com/mateimicu/kdiscover/workflows/Lint%20&%20build%20Golang%20project/badge.svg?branch=master)
[![CI](https://github.com/mateimicu/kdiscover/actions/workflows/golang-ci.yaml/badge.svg?branch=master)](https://github.com/mateimicu/kdiscover/actions/workflows/golang-ci.yaml)
![CodeQL](https://github.com/mateimicu/kdiscover/workflows/CodeQL/badge.svg)
[![codecov](https://codecov.io/gh/mateimicu/kdiscover/branch/master/graph/badge.svg)](https://codecov.io/gh/mateimicu/kdiscover)
![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/mateimicu/kdiscover?sort=semver)
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func newAWSCommand() *cobra.Command {
// An issue about this https://github.com/spf13/cobra/issues/252
root := cmd
for ; root.HasParent(); root = root.Parent() {
}
} //revive:disable-line:empty-block
err := root.PersistentPreRunE(cmd, args)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion cmd/aws_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (

type mockExportable struct{}

func (mockExportable) IsExported(cls kubeconfig.Endpointer) bool {
func (mockExportable) IsExported(_ kubeconfig.Endpointer) bool {
return false
}

Expand Down
4 changes: 2 additions & 2 deletions cmd/aws_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func backupKubeConfig(kubeconfigPath string) (string, error) {
"err": err.Error(),
}).Info("Can't generate backup file name ")
}
err = copy(kubeconfigPath, bName)
err = copyFs(kubeconfigPath, bName)
if err != nil {
return "", err
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func newUpdateCommand() *cobra.Command {
return updateCommand
}

func copy(src, dst string) error {
func copyFs(src, dst string) error {
sourceFileStat, err := os.Stat(src)
if err != nil {
return err
Expand Down
18 changes: 11 additions & 7 deletions internal/aws/eks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ func (c *mockEKSClient) ListClustersPages(_ *eks.ListClustersInput, fn func(*eks

// prepare clusters
for _, cls := range c.Clusters[start:end] {
clusters = append(clusters, &cls.Name)
localCluster := *cls
clusters = append(clusters, &localCluster.Name)
}
o.Clusters = clusters
lastPage := end == len(c.Clusters)
Expand All @@ -80,12 +81,13 @@ func (c *mockEKSClient) DescribeCluster(input *eks.DescribeClusterInput) (*eks.D
}

for _, cls := range c.Clusters {
localCluster := *cls
if *input.Name == cls.Name {
cluster := eks.Cluster{}
cluster.Arn = &cls.ID
cluster.Endpoint = &cls.Endpoint
cluster.Name = &cls.Name
cluster.Status = &cls.Status
cluster.Arn = &localCluster.ID
cluster.Endpoint = &localCluster.Endpoint
cluster.Name = &localCluster.Name
cluster.Status = &localCluster.Status

cert := eks.Certificate{}
data := base64.StdEncoding.EncodeToString([]byte(cls.CertificateAuthorityData))
Expand Down Expand Up @@ -238,6 +240,7 @@ func TestGetClustersNoFailure(t *testing.T) {
t.Parallel()
log.SetOutput(ioutil.Discard)
for _, tt := range cases {
client := tt.Client
describeErrorCount := 0
for k := range tt.Client.ErrorOnDescribe {
if k > len(tt.Client.Clusters) {
Expand All @@ -258,7 +261,7 @@ func TestGetClustersNoFailure(t *testing.T) {
t.Run(testname, func(t *testing.T) {
ch := make(chan *cluster.Cluster)
c := EKSClient{
EKS: &tt.Client,
EKS: &client,
Region: tt.Region,
}
go c.GetClusters(ch)
Expand Down Expand Up @@ -311,6 +314,7 @@ func TestGetClustersListFailure(t *testing.T) {
},
}
for _, tt := range tts {
client := tt.Client
describeErrorCount := 0
for k := range tt.Client.ErrorOnDescribe {
if k > len(tt.Client.Clusters) {
Expand All @@ -331,7 +335,7 @@ func TestGetClustersListFailure(t *testing.T) {
t.Run(testname, func(t *testing.T) {
ch := make(chan *cluster.Cluster)
c := EKSClient{
EKS: &tt.Client,
EKS: &client,
Region: tt.Region,
}
go c.GetClusters(ch)
Expand Down
2 changes: 1 addition & 1 deletion internal/cluster/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func randomString(length int) string {
return stringWithCharset(length, charset)
}

func dummyGenerateAuthInfo(cls *Cluster) *clientcmdapi.AuthInfo {
func dummyGenerateAuthInfo(_ *Cluster) *clientcmdapi.AuthInfo {
return clientcmdapi.NewAuthInfo()
}

Expand Down

0 comments on commit 6b78e1c

Please sign in to comment.