mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-27 13:15:36 +00:00
hack: integrate logcheck into golangci-lint
Running logcheck as part of golangci-lint has several advantages: - faster checking because finding files and parsing is shared with other linters - gets rid of the complex and buggy hack/verify-structured-logging.sh (https://github.com/kubernetes/kubernetes/issues/106746) - support for // nolint:logcheck - works with Go 1.18
This commit is contained in:
@@ -36,14 +36,25 @@ PATH="${GOBIN}:${PATH}"
|
||||
export GO111MODULE=on
|
||||
|
||||
# Install golangci-lint
|
||||
echo 'installing golangci-lint '
|
||||
echo "installing golangci-lint and logcheck plugin from hack/tools into ${GOBIN}"
|
||||
pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||
go install github.com/golangci/golangci-lint/cmd/golangci-lint
|
||||
go build -o "${GOBIN}/logcheck.so" -buildmode=plugin k8s.io/klog/hack/tools/logcheck/plugin
|
||||
popd >/dev/null
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
# The config is in ${KUBE_ROOT}/.golangci.yaml
|
||||
# The config is in ${KUBE_ROOT}/.golangci.yaml where it will be found
|
||||
# even when golangci-lint is invoked in a sub-directory.
|
||||
#
|
||||
# The logcheck plugin currently has to be configured via env variables
|
||||
# (https://github.com/golangci/golangci-lint/issues/1512).
|
||||
#
|
||||
# Remember to clean the golangci-lint cache when changing
|
||||
# the configuration and running this script multiple times,
|
||||
# otherwise golangci-lint will report stale results:
|
||||
# _output/local/bin/golangci-lint cache clean
|
||||
export LOGCHECK_CONFIG="${KUBE_ROOT}/hack/logcheck.conf"
|
||||
echo 'running golangci-lint ' >&2
|
||||
res=0
|
||||
if [[ "$#" -gt 0 ]]; then
|
||||
|
Reference in New Issue
Block a user