Skip to content

Commit 4db9cf8

Browse files
committed
update golangci-lint to v2.3.0
Signed-off-by: dongjiang <[email protected]> add TODO comment && change code Signed-off-by: dongjiang <[email protected]>
1 parent 122cac9 commit 4db9cf8

File tree

15 files changed

+40
-23
lines changed

15 files changed

+40
-23
lines changed

.github/workflows/pr-golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: golangci-lint
3131
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # tag=v8.0.0
3232
with:
33-
version: v2.1.0
33+
version: v2.3.0
3434
working-directory: ${{matrix.working-directory}}
3535
- name: Lint API
3636
run: make lint-api

.golangci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,19 @@ linters:
269269
- linters:
270270
- staticcheck
271271
text: 'SA1019: .*(res|result|i|j)\.Requeue is deprecated: Use `RequeueAfter` instead'
272+
# TODO: var-naming: avoid meaningless package names by revive
273+
# * test/infrastructure/docker/internal/docker/types/
274+
# * bootstrap/kubeadm/types/
275+
# * internal/webhooks/util/
276+
# * util/
277+
# * exp/util/
278+
# * controlplane/kubeadm/internal/etcd/util/
279+
# * cmd/clusterctl/internal/util/
280+
# * bootstrap/util/
281+
- linters:
282+
- revive
283+
text: 'var-naming: avoid meaningless package names'
284+
path: test/infrastructure/docker/internal/docker/types/.*\.go$|bootstrap/kubeadm/types/.*\.go$|internal/webhooks/util/.*\.go$|util/.*\.go$|exp/util/.*\.go$|controlplane/kubeadm/internal/etcd/util/.*\.go$|cmd/clusterctl/internal/util/.*\.go$|bootstrap/util/.*\.go$
272285
- linters:
273286
- revive
274287
text: 'exported: exported method .*\.(Reconcile|SetupWithManager|SetupWebhookWithManager) should have comment or be unexported'

bootstrap/kubeadm/types/doc.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package utils contains Kubeadm utility types.
18-
package utils
17+
// Package types contains Kubeadm utility types.
18+
package types

bootstrap/kubeadm/types/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
// Package utils contains Kubeadm utility types.
18-
package utils
17+
// Package types contains Kubeadm utility types.
18+
package types
1919

2020
import (
2121
"github.com/blang/semver/v4"

bootstrap/kubeadm/types/utils_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package utils
17+
package types
1818

1919
import (
2020
"fmt"

hack/tools/.custom-gcl.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: v2.1.0
1+
version: v2.3.0
22
name: golangci-lint-kube-api-linter
33
destination: ./bin
44
plugins:

hack/tools/internal/tilt-prepare/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ type tiltProviderConfig struct {
145145
}
146146

147147
func init() {
148-
cmd := exec.Command("git", "rev-parse", "--show-toplevel")
148+
cmd := exec.Command("git", "rev-parse", "--show-toplevel") //nolint:noctx
149149
var stdout, stderr bytes.Buffer
150150
cmd.Stdout = &stdout
151151
cmd.Stderr = &stderr

hack/tools/release/notes/github.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ func (c githubClient) listMergedPRs(after, before time.Time, baseBranches ...str
165165
}
166166

167167
func (c githubClient) runGHAPICommand(url string, response any) error {
168-
cmd := exec.Command("gh", "api", url)
168+
cmd := exec.Command("gh", "api", url) //nolint:noctx
169169

170170
out, err := cmd.CombinedOutput()
171171
if err != nil {

internal/test/envtest/environment.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ func (e *Environment) start(ctx context.Context) {
417417
}
418418
}()
419419
<-e.Elected()
420-
e.waitForWebhooks()
420+
e.waitForWebhooks(ctx)
421421
}
422422

423423
// stop stops the test environment.
@@ -428,14 +428,17 @@ func (e *Environment) stop() error {
428428
}
429429

430430
// waitForWebhooks waits for the webhook server to be available.
431-
func (e *Environment) waitForWebhooks() {
431+
func (e *Environment) waitForWebhooks(ctx context.Context) {
432432
port := e.env.WebhookInstallOptions.LocalServingPort
433433

434434
klog.V(2).Infof("Waiting for webhook port %d to be open prior to running tests", port)
435435
timeout := 1 * time.Second
436436
for {
437437
time.Sleep(1 * time.Second)
438-
conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)), timeout)
438+
dialer := &net.Dialer{
439+
Timeout: timeout,
440+
}
441+
conn, err := dialer.DialContext(ctx, "tcp", net.JoinHostPort("127.0.0.1", strconv.Itoa(port)))
439442
if err != nil {
440443
klog.V(2).Infof("Webhook port is not ready, will retry in %v: %s", timeout, err)
441444
continue

test/framework/clusterctl/client.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ func Init(ctx context.Context, input InitInput) {
9191
}
9292

9393
// InitWithBinary uses clusterctl binary to run init with the list of providers defined in the local repository.
94-
func InitWithBinary(_ context.Context, binary string, input InitInput) {
94+
func InitWithBinary(ctx context.Context, binary string, input InitInput) {
9595
args := calculateClusterCtlInitArgs(input, binary)
9696
log.Logf("clusterctl %s", strings.Join(args, " "))
9797

98-
cmd := exec.Command(binary, args...) //nolint:gosec // We don't care about command injection here.
98+
cmd := exec.CommandContext(ctx, binary, args...) //nolint:gosec // We don't care about command injection here.
9999

100100
out, err := cmd.CombinedOutput()
101101
_ = os.WriteFile(filepath.Join(input.LogFolder, "clusterctl-init.log"), out, 0644) //nolint:gosec // this is a log file to be shared via prow artifacts
@@ -217,7 +217,7 @@ func UpgradeWithBinary(ctx context.Context, binary string, input UpgradeInput) e
217217
args := calculateClusterCtlUpgradeArgs(input)
218218
log.Logf("clusterctl %s", strings.Join(args, " "))
219219

220-
cmd := exec.Command(binary, args...) //nolint:gosec // We don't care about command injection here.
220+
cmd := exec.CommandContext(ctx, binary, args...) //nolint:gosec // We don't care about command injection here.
221221

222222
out, err := cmd.CombinedOutput()
223223
_ = os.WriteFile(filepath.Join(input.LogFolder, "clusterctl-upgrade.log"), out, 0644) //nolint:gosec // this is a log file to be shared via prow artifacts
@@ -374,7 +374,7 @@ func ConfigCluster(ctx context.Context, input ConfigClusterInput) []byte {
374374
// ConfigClusterWithBinary uses clusterctl binary to run config cluster or generate cluster.
375375
// NOTE: This func detects the clusterctl version and uses config cluster or generate cluster
376376
// accordingly. We can drop the detection when we don't have to support clusterctl v0.3.x anymore.
377-
func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, input ConfigClusterInput) []byte {
377+
func ConfigClusterWithBinary(ctx context.Context, clusterctlBinaryPath string, input ConfigClusterInput) []byte {
378378
version, err := getClusterCtlVersion(clusterctlBinaryPath)
379379
Expect(err).ToNot(HaveOccurred())
380380
clusterctlSupportsGenerateCluster := version.GTE(semver.MustParse("1.0.0"))
@@ -401,7 +401,7 @@ func ConfigClusterWithBinary(_ context.Context, clusterctlBinaryPath string, inp
401401
}
402402
log.Logf("clusterctl %s", strings.Join(args, " "))
403403

404-
cmd := exec.Command(clusterctlBinaryPath, args...) //nolint:gosec // We don't care about command injection here.
404+
cmd := exec.CommandContext(ctx, clusterctlBinaryPath, args...) //nolint:gosec // We don't care about command injection here.
405405
out, err := cmd.Output()
406406
_ = os.WriteFile(filepath.Join(input.LogFolder, fmt.Sprintf("%s-cluster-template.yaml", input.ClusterName)), out, 0644) //nolint:gosec // this is a log file to be shared via prow artifacts
407407
var stdErr string

0 commit comments

Comments
 (0)