Skip to content

chore: upgrade golangci-lint to 2.1.6 #1657

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
40 changes: 28 additions & 12 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
run:
timeout: 10m

version: "2"
linters:
disable-all: true
default: none
enable:
- bodyclose
- copyloopvar
- dogsled
- dupl
- errcheck
- copyloopvar
- exhaustive
- gocritic
- gocyclo
- gofmt
- goimports
- goprintffuncname
- gosimple
- govet
- ineffassign
- misspell
Expand All @@ -25,7 +20,28 @@ linters:
- unconvert
- unused
- whitespace

linters-settings:
goimports:
local-prefixes: sigs.k8s.io/metrics-server
exclusions:
generated: lax
presets:
- comments
- common-false-positives
- legacy
- std-error-handling
paths:
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
settings:
goimports:
local-prefixes:
- sigs.k8s.io/metrics-server
exclusions:
generated: lax
paths:
- third_party$
- builtin$
- examples$
Copy link
Member Author

Choose a reason for hiding this comment

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

This file was updated running the command golangci-lint migrate as mentioned in https://golangci-lint.run/product/migration-guide/

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ ALL_BINARIES_PLATFORMS= $(addprefix linux/,$(ALL_ARCHITECTURES)) \

# Tools versions
# --------------
GOLANGCI_VERSION:=1.64.8
GOLANGCI_VERSION:=2.1.6

# Computed variables
# ------------------
Expand Down
18 changes: 9 additions & 9 deletions cmd/metrics-server/app/options/kubelet_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ func (o KubeletClientOptions) Config(restConfig *rest.Config) *client.KubeletCli
config.Client.TLSClientConfig = rest.TLSClientConfig{} // empty TLS config --> no TLS
}
if o.InsecureKubeletTLS {
config.Client.TLSClientConfig.Insecure = true
config.Client.TLSClientConfig.CAData = nil
config.Client.TLSClientConfig.CAFile = ""
config.Client.TLSClientConfig.Insecure = true //nolint:staticcheck
Copy link
Member Author

Choose a reason for hiding this comment

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

//nolint was added for the lint issue QF1008: could remove embedded field "TLSClientConfig" from selector (staticcheck).

I believe we need this current code instead of linter recommendation.

config.Client.TLSClientConfig.CAData = nil //nolint:staticcheck
config.Client.TLSClientConfig.CAFile = "" //nolint:staticcheck
}
if len(o.KubeletCAFile) > 0 {
config.Client.TLSClientConfig.CAFile = o.KubeletCAFile
config.Client.TLSClientConfig.CAData = nil
config.Client.TLSClientConfig.CAFile = o.KubeletCAFile //nolint:staticcheck
config.Client.TLSClientConfig.CAData = nil //nolint:staticcheck
}
if len(o.KubeletClientCertFile) > 0 {
config.Client.TLSClientConfig.CertFile = o.KubeletClientCertFile
config.Client.TLSClientConfig.CertData = nil
config.Client.TLSClientConfig.CertFile = o.KubeletClientCertFile //nolint:staticcheck
config.Client.TLSClientConfig.CertData = nil //nolint:staticcheck
}
if len(o.KubeletClientKeyFile) > 0 {
config.Client.TLSClientConfig.KeyFile = o.KubeletClientKeyFile
config.Client.TLSClientConfig.KeyData = nil
config.Client.TLSClientConfig.KeyFile = o.KubeletClientKeyFile //nolint:staticcheck
config.Client.TLSClientConfig.KeyData = nil //nolint:staticcheck
}
return config
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/metrics-server/app/options/kubelet_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ func TestConfig(t *testing.T) {
},
expectFunc: func() client.KubeletClientConfig {
e := expected
e.Client.TLSClientConfig.CertFile = "Override"
e.Client.TLSClientConfig.CertData = nil
e.Client.TLSClientConfig.CertFile = "Override" //nolint:staticcheck
e.Client.TLSClientConfig.CertData = nil //nolint:staticcheck
return e
},
},
Expand All @@ -135,8 +135,8 @@ func TestConfig(t *testing.T) {
},
expectFunc: func() client.KubeletClientConfig {
e := expected
e.Client.TLSClientConfig.KeyFile = "Override"
e.Client.TLSClientConfig.KeyData = nil
e.Client.TLSClientConfig.KeyFile = "Override" //nolint:staticcheck
e.Client.TLSClientConfig.KeyData = nil //nolint:staticcheck
return e
},
},
Expand Down