diff --git a/hack/golangci-hints.yaml b/hack/golangci-hints.yaml index 90863541f27..c2ce0914f78 100644 --- a/hack/golangci-hints.yaml +++ b/hack/golangci-hints.yaml @@ -48,7 +48,7 @@ issues: # Adding unversioned feature gates is allowed in tests - linters: - forbidigo - text: should not use MutableFeatureGate.Add, use AddVersioned instead + text: should not use Add, use AddVersioned instead path: _test.go$ # The Kubernetes naming convention for conversion functions uses underscores @@ -205,8 +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$ - type: ^MutableFeatureGate$ - 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 f7c834116f3..5daa137e02a 100644 --- a/hack/golangci.yaml +++ b/hack/golangci.yaml @@ -48,7 +48,7 @@ issues: # Adding unversioned feature gates is allowed in tests - linters: - forbidigo - text: should not use MutableFeatureGate.Add, use AddVersioned instead + text: should not use Add, use AddVersioned instead path: _test.go$ # TODO(oscr) Remove these excluded directories and fix findings. Due to large amount of findings in different components @@ -271,8 +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$ - type: ^MutableFeatureGate$ - 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 6c6ed5e99c6..a2987c4b33b 100644 --- a/hack/golangci.yaml.in +++ b/hack/golangci.yaml.in @@ -48,7 +48,7 @@ issues: # Adding unversioned feature gates is allowed in tests - linters: - forbidigo - text: should not use MutableFeatureGate.Add, use AddVersioned instead + text: should not use Add, use AddVersioned instead path: _test.go$ {{- if .Base}} @@ -223,8 +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$ - type: ^MutableFeatureGate$ - 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.sh b/hack/verify-golangci-lint.sh index 72d8a9382ef..8e48200567a 100755 --- a/hack/verify-golangci-lint.sh +++ b/hack/verify-golangci-lint.sh @@ -129,6 +129,22 @@ if [ "${golangci_config}" ]; then GOTOOLCHAIN="$(kube::golang::hack_tools_gotoolchain)" go -C "${KUBE_ROOT}/hack/tools" build -o "${GOBIN}/logcheck.so" -buildmode=plugin sigs.k8s.io/logtools/logcheck/plugin fi +# Verify that the given config is valid. "golangci-lint run" does not +# do that, which makes it easy to miss mistakes while editing the configuration. +if ! failures=$( "${GOBIN}/golangci-lint" config verify --config="${golangci_config:-}" 2>&1 ); then + cat >&2 <