From a9d558de26335bc5b41e8722a33b6e398db2d7c9 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 10 Mar 2025 12:06:56 +0200 Subject: [PATCH] hack: verify golangci-lint config, update text --- hack/golangci-hints.yaml | 2 +- hack/golangci.yaml | 2 +- hack/golangci.yaml.in | 2 +- hack/verify-golangci-lint-config.sh | 7 ++++++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index b716ea07e60..2ac2132b289 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -205,7 +205,7 @@ linters-settings: # please keep this alphabetized msg: should not be used because managedFields was removed - p: \.Add$ pkg: ^k8s\.io/component-base/featuregate$ - msg: should not use MutableFeatureGate.Add, use AddVersioned instead + msg: should not use Add, use AddVersioned instead - p: ^gomega\.BeTrue$ pkg: ^github.com/onsi/gomega$ msg: "it does not produce a good failure message - use BeTrueBecause with an explicit printf-style failure message instead, or plain Go: if ... { ginkgo.Fail(...) }" diff --git a/hack/golangci.yaml b/hack/golangci.yaml index 34c4e3ab632..7972d00d5c0 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -271,7 +271,7 @@ linters-settings: # please keep this alphabetized msg: should not be used because managedFields was removed - p: \.Add$ pkg: ^k8s\.io/component-base/featuregate$ - msg: should not use MutableFeatureGate.Add, use AddVersioned instead + msg: should not use Add, use AddVersioned instead gocritic: enabled-checks: - equalFold diff --git a/hack/golangci.yaml.in b/hack/golangci.yaml.in index 06ad332b8d0..3ff7507143e 100644 --- a/hack/golangci.yaml.in +++ b/hack/golangci.yaml.in @@ -223,7 +223,7 @@ linters-settings: # please keep this alphabetized msg: should not be used because managedFields was removed - p: \.Add$ pkg: ^k8s\.io/component-base/featuregate$ - msg: should not use MutableFeatureGate.Add, use AddVersioned instead + msg: should not use Add, use AddVersioned instead {{- if .Hints}} - p: ^gomega\.BeTrue$ pkg: ^github.com/onsi/gomega$ diff --git a/hack/verify-golangci-lint-config.sh b/hack/verify-golangci-lint-config.sh index 236d3e589e5..83d11147599 100755 --- a/hack/verify-golangci-lint-config.sh +++ b/hack/verify-golangci-lint-config.sh @@ -15,7 +15,7 @@ # limitations under the License. # This script checks that all generated golangci-lint configurations -# are up-to-date. +# are up-to-date and the config hack/golangci.yaml is valid. set -o errexit set -o nounset @@ -24,4 +24,9 @@ set -o pipefail KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/verify-generated.sh" +golangci=("${GOBIN}/golangci-lint") +golangci_config="${KUBE_ROOT}/hack/golangci.yaml" + kube::verify::generated "" "Please run 'hack/update-golangci-lint-config.sh'" hack/update-golangci-lint-config.sh + +"${golangci[@]}" config verify --config="${golangci_config}"