From 50cb4635618d36dcc587a421146dae975e5ac577 Mon Sep 17 00:00:00 2001 From: Alan Greene Date: Mon, 16 Dec 2024 00:57:54 +0000 Subject: [PATCH] Bump golangci-lint from 1.56.2 to 1.62.2 --- .github/workflows/pr.yml | 2 +- .golangci.yml | 39 ++++++++++++++++++++++++++++----------- pkg/utils/proxy.go | 4 ++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index a5eadb013..5a5259705 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -43,7 +43,7 @@ jobs: GO111MODULE="on" go install github.com/google/go-licenses@v1.0.0 # Install GolangCI linter: https://github.com/golangci/golangci-lint/ - GOLANGCI_VERSION=1.56.2 + GOLANGCI_VERSION=1.62.2 curl -sL https://github.com/golangci/golangci-lint/releases/download/v${GOLANGCI_VERSION}/golangci-lint-${GOLANGCI_VERSION}-linux-amd64.tar.gz | tar -C /usr/local/bin -xvzf - --strip-components=1 --wildcards "*/golangci-lint" - name: Run tests diff --git a/.golangci.yml b/.golangci.yml index 9af203b48..f49e440a5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,26 @@ +# Documentation: https://golangci-lint.run/usage/configuration/ + linters-settings: - errcheck: - exclude: .errcheck.txt + gomodguard: + blocked: + modules: + - github.com/ghodss/yaml: + recommendations: + - sigs.k8s.io/yaml + depguard: + rules: + prevent_unmaintained_packages: + list-mode: lax # allow unless explicitely denied + files: + - $all + - "!$test" + allow: + - $gostd + deny: + - pkg: io/ioutil + desc: "replaced by io and os packages since Go 1.16: https://tip.golang.org/doc/go1.16#ioutil" + - pkg: github.com/ghodss/yaml + desc: "use sigs.k8s.io/yaml instead, to be consistent" linters: enable: - bodyclose @@ -42,6 +62,7 @@ linters: - cyclop - depguard - dupl + - err113 - exhaustruct - forcetypeassert - funlen @@ -52,19 +73,20 @@ linters: - gocyclo - godot - godox - - goerr113 - gofumpt - - gomnd - gomoddirectives + - iface - ireturn - lll - mirror + - mnd - nestif - nlreturn - nonamedreturns - paralleltest - prealloc - predeclared + - recvcheck - revive - staticcheck - stylecheck @@ -98,17 +120,12 @@ output: issues: exclude-dirs: - vendor - exclude-rules: - - path: _test\.go - linters: - - errcheck - - gosec max-issues-per-linter: 0 max-same-issues: 0 include: # Enable off-by-default rules for revive requiring that all exported elements have a properly formatted comment. - - EXC0012 - - EXC0014 + - EXC0012 # https://golangci-lint.run/usage/false-positives/#exc0012 + - EXC0014 # https://golangci-lint.run/usage/false-positives/#exc0014 run: issues-exit-code: 1 build-tags: diff --git a/pkg/utils/proxy.go b/pkg/utils/proxy.go index 1ebcf8698..1c7115b4a 100644 --- a/pkg/utils/proxy.go +++ b/pkg/utils/proxy.go @@ -1,5 +1,5 @@ /* -Copyright 2020-2022 The Tekton Authors +Copyright 2020-2024 The Tekton Authors Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at @@ -31,7 +31,7 @@ func Proxy(request *http.Request, response http.ResponseWriter, url string, clie req = req.WithContext(request.Context()) - if request.Method == "POST" || request.Method == "PATCH" || request.Method == "PUT" || request.Method == "DELETE" { + if request.Method == http.MethodPost || request.Method == http.MethodPatch || request.Method == http.MethodPut || request.Method == http.MethodDelete { req.Header.Set("Content-Type", request.Header.Get("Content-Type")) }