mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 12:41:58 +00:00
Mark staging go module files as generated, add script to lint dependencies
This commit is contained in:
@@ -35,7 +35,7 @@ export GOPATH=
|
||||
export GOFLAGS=
|
||||
# Detect problematic GOPROXY settings that prevent lookup of dependencies
|
||||
if [[ "${GOPROXY:-}" == "off" ]]; then
|
||||
kube::log::error "Cannot run hack/pin-dependency.sh with \$GOPROXY=off"
|
||||
kube::log::error "Cannot run with \$GOPROXY=off"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -54,12 +54,37 @@ if [[ -z "${dep}" || -z "${sha}" ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
_tmp="${KUBE_ROOT}/_tmp"
|
||||
cleanup() {
|
||||
rm -rf "${_tmp}"
|
||||
}
|
||||
trap "cleanup" EXIT SIGINT
|
||||
cleanup
|
||||
mkdir -p "${_tmp}"
|
||||
|
||||
# Add the require directive
|
||||
echo "Running: go get ${dep}@${sha}"
|
||||
go get -d "${dep}@${sha}"
|
||||
|
||||
# Find the resolved version
|
||||
rev=$(go mod edit -json | jq -r ".Require[] | select(.Path == \"${dep}\") | .Version")
|
||||
|
||||
# No entry in go.mod, we must be using the natural version indirectly
|
||||
if [[ -z "${rev}" ]]; then
|
||||
# backup the go.mod file, since go list modifies it
|
||||
cp go.mod "${_tmp}/go.mod.bak"
|
||||
# find the revision
|
||||
rev=$(go list -m -json "${dep}" | jq -r .Version)
|
||||
# restore the go.mod file
|
||||
mv "${_tmp}/go.mod.bak" go.mod
|
||||
fi
|
||||
|
||||
# No entry found
|
||||
if [[ -z "${rev}" ]]; then
|
||||
echo "Could not resolve ${sha}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Resolved to ${dep}@${rev}"
|
||||
|
||||
# Add the replace directive
|
||||
|
Reference in New Issue
Block a user