mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Merge pull request #40659 from sttts/sttts-print-staging-import-cycles
Automatic merge from submit-queue (batch tested with PRs 40703, 40093, 40618, 40659, 39810) hack/verify-staging-imports.sh: print actual dependencies Example: ```shell $ hack/verify-staging-imports.sh apiserver has a forbidden dependency: k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/api/errors k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/api/meta k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/runtime k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/runtime/schema k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/util/errors k8s.io/apiserver/pkg/admission imports k8s.io/apimachinery/pkg/util/sets ```
This commit is contained in:
commit
2975475e35
@ -23,13 +23,39 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
|||||||
|
|
||||||
kube::golang::setup_env
|
kube::golang::setup_env
|
||||||
|
|
||||||
|
function print_forbidden_imports () {
|
||||||
for dep in $(ls -1 ${KUBE_ROOT}/staging/src/k8s.io/); do
|
set -o errexit # this was unset by ||
|
||||||
if go list -f {{.Deps}} ./vendor/k8s.io/${dep}/... | tr " " '\n' | grep k8s.io/kubernetes | grep -v 'k8s.io/kubernetes/vendor' | LC_ALL=C sort -u | grep -e "."; then
|
local PACKAGE="$1"
|
||||||
echo "${dep} has a cyclical dependency"
|
shift
|
||||||
exit 1
|
local RE=""
|
||||||
|
local SEP=""
|
||||||
|
for CLAUSE in "$@"; do
|
||||||
|
RE+="${SEP}${CLAUSE}"
|
||||||
|
SEP='\|'
|
||||||
|
done
|
||||||
|
local FORBIDDEN=$(
|
||||||
|
go list -f $'{{with $package := .ImportPath}}{{range $.Imports}}{{$package}} imports {{.}}\n{{end}}{{end}}' ./vendor/k8s.io/${PACKAGE}/... |
|
||||||
|
sed 's|^k8s.io/kubernetes/vendor/||;s| k8s.io/kubernetes/vendor/| |' |
|
||||||
|
grep -v " k8s.io/${PACKAGE}" |
|
||||||
|
grep -e "imports \(${RE}\)"
|
||||||
|
)
|
||||||
|
if [ -n "${FORBIDDEN}" ]; then
|
||||||
|
echo "${PACKAGE} has a forbidden dependency:"
|
||||||
|
echo
|
||||||
|
echo "${FORBIDDEN}" | sed 's/^/ /'
|
||||||
|
echo
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
done
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
RC=0
|
||||||
|
print_forbidden_imports apimachinery k8s.io/ || RC=1
|
||||||
|
print_forbidden_imports apiserver k8s.io/kubernetes || RC=1
|
||||||
|
print_forbidden_imports client-go k8s.io/kubernetes k8s.io/apiserver || RC=1
|
||||||
|
if [ ${RC} != 0 ]; then
|
||||||
|
exit ${RC}
|
||||||
|
fi
|
||||||
|
|
||||||
if grep -rq '// import "k8s.io/kubernetes/' 'staging/'; then
|
if grep -rq '// import "k8s.io/kubernetes/' 'staging/'; then
|
||||||
echo 'file has "// import "k8s.io/kubernetes/"'
|
echo 'file has "// import "k8s.io/kubernetes/"'
|
||||||
|
Loading…
Reference in New Issue
Block a user