mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-16 07:13:53 +00:00
Add guard for dependencies recursively depending on kubernetes or staging modules
This commit is contained in:
parent
48d6d55a47
commit
83f2b390b7
@ -47,6 +47,19 @@ rc=0
|
||||
# The array and map in `unwanted-dependencies.json` are in alphabetical order.
|
||||
go run k8s.io/kubernetes/cmd/dependencyverifier "${KUBE_ROOT}/hack/unwanted-dependencies.json"
|
||||
|
||||
k8s_module_regex="k8s[.]io/(kubernetes"
|
||||
for repo in $(kube::util::list_staging_repos); do
|
||||
k8s_module_regex="${k8s_module_regex}|${repo}"
|
||||
done
|
||||
k8s_module_regex="${k8s_module_regex})"
|
||||
|
||||
recursive_dependencies=$(go mod graph | grep -E " ${k8s_module_regex}" | grep -E -v "^${k8s_module_regex}" || true)
|
||||
if [[ -n "${recursive_dependencies}" ]]; then
|
||||
echo "These external modules depend on k8s.io/kubernetes or staging modules, which is not allowed:"
|
||||
echo ""
|
||||
echo "${recursive_dependencies}"
|
||||
fi
|
||||
|
||||
outdated=$(go list -m -json all | jq -r "
|
||||
select(.Replace.Version != null) |
|
||||
select(.Version != .Replace.Version) |
|
||||
@ -90,7 +103,7 @@ if [[ -n "${unused}" ]]; then
|
||||
echo "${unused}" | xargs -L 1 echo 'go mod edit -dropreplace'
|
||||
fi
|
||||
|
||||
if [[ -n "${unused}${outdated}${noncanonical}" ]]; then
|
||||
if [[ -n "${unused}${outdated}${noncanonical}${recursive_dependencies}" ]]; then
|
||||
rc=1
|
||||
else
|
||||
echo "All pinned versions of checked dependencies match their preferred version."
|
||||
|
Loading…
Reference in New Issue
Block a user