mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
hack: verify to verify-golangci-lint.sh
This commit is contained in:
parent
67f0e95b3a
commit
77758c185b
@ -15,7 +15,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
# This script checks that all generated golangci-lint configurations
|
# This script checks that all generated golangci-lint configurations
|
||||||
# are up-to-date and the config hack/golangci.yaml is valid.
|
# are up-to-date.
|
||||||
|
|
||||||
set -o errexit
|
set -o errexit
|
||||||
set -o nounset
|
set -o nounset
|
||||||
@ -24,9 +24,4 @@ set -o pipefail
|
|||||||
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||||
source "${KUBE_ROOT}/hack/lib/verify-generated.sh"
|
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
|
kube::verify::generated "" "Please run 'hack/update-golangci-lint-config.sh'" hack/update-golangci-lint-config.sh
|
||||||
|
|
||||||
"${golangci[@]}" config verify --config="${golangci_config}"
|
|
||||||
|
@ -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
|
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
|
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 <<EOF
|
||||||
|
|
||||||
|
Verification of the configuration failed. Command:
|
||||||
|
|
||||||
|
${GOBIN}/golangci-lint config verify --config="${golangci_config:-}")
|
||||||
|
|
||||||
|
Result:
|
||||||
|
|
||||||
|
$failures
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "${golangci_config}" ]; then
|
if [ "${golangci_config}" ]; then
|
||||||
# The relative path to _output/local/bin only works if that actually is the
|
# The relative path to _output/local/bin only works if that actually is the
|
||||||
# GOBIN. If not, then we have to make a temporary copy of the config and
|
# GOBIN. If not, then we have to make a temporary copy of the config and
|
||||||
|
Loading…
Reference in New Issue
Block a user