mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-05 18:24:07 +00:00
verify-golangci-lint.sh: support arbitrary GOBIN
The in-tree configs use a relative path to find logcheck.so. This is useful because then the invocation of golangci-lint also works outside of the script. But when running with a containerized build, GOBIN points somewhere else. For that case, a temporary copy of the configuration has to be created with an absolute path.
This commit is contained in:
parent
f8a4e343a1
commit
d20edf697a
@ -106,10 +106,6 @@ while getopts "ar:sng:c:" o; do
|
||||
esac
|
||||
done
|
||||
|
||||
if [ "${golangci_config}" ]; then
|
||||
golangci+=(--config="${golangci_config}")
|
||||
fi
|
||||
|
||||
# Below the output of golangci-lint is going to be piped into sed to add
|
||||
# a prefix to each output line. This helps make the output more visible
|
||||
# in the Prow log viewer ("error" is a key word there) and ensures that
|
||||
@ -159,6 +155,22 @@ pushd "${KUBE_ROOT}/hack/tools" >/dev/null
|
||||
fi
|
||||
popd >/dev/null
|
||||
|
||||
if [ "${golangci_config}" ]; then
|
||||
# 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
|
||||
# replace the path with an absolute one. This could be done also
|
||||
# unconditionally, but the invocation that is printed below is nicer if we
|
||||
# don't to do it when not required.
|
||||
if grep -q 'path: ../_output/local/bin/' "${golangci_config}" &&
|
||||
[ "${GOBIN}" != "${KUBE_ROOT}/_output/local/bin" ]; then
|
||||
kube::util::ensure-temp-dir
|
||||
patched_golangci_config="${KUBE_TEMP}/$(basename "${golangci_config}")"
|
||||
sed -e "s;path: ../_output/local/bin/;path: ${GOBIN}/;" "${golangci_config}" >"${patched_golangci_config}"
|
||||
golangci_config="${patched_golangci_config}"
|
||||
fi
|
||||
golangci+=(--config="${golangci_config}")
|
||||
fi
|
||||
|
||||
cd "${KUBE_ROOT}"
|
||||
|
||||
res=0
|
||||
|
Loading…
Reference in New Issue
Block a user