mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
verify-staging-import: ignore k8s.io/kube-gen/test
This commit is contained in:
parent
98042b77f3
commit
927341c6d3
@ -25,7 +25,14 @@ kube::golang::setup_env
|
||||
|
||||
function print_forbidden_imports () {
|
||||
set -o errexit # this was unset by ||
|
||||
local PACKAGE="$1"
|
||||
local REPO="${1%%/*}" # everything in front of the /
|
||||
|
||||
# find packages with extended glob support of bash (supports inversion)
|
||||
local PACKAGES=($(
|
||||
shopt -s extglob;
|
||||
eval ls -d -1 ./vendor/k8s.io/${1}/
|
||||
))
|
||||
|
||||
shift
|
||||
local RE=""
|
||||
local SEP=""
|
||||
@ -34,28 +41,28 @@ function print_forbidden_imports () {
|
||||
SEP='\|'
|
||||
done
|
||||
local FORBIDDEN=$(
|
||||
go list -f $'{{with $package := .ImportPath}}{{range $.Imports}}{{$package}} imports {{.}}\n{{end}}{{end}}' ./vendor/k8s.io/${PACKAGE}/... |
|
||||
go list -f $'{{with $package := .ImportPath}}{{range $.Imports}}{{$package}} imports {{.}}\n{{end}}{{end}}' "${PACKAGES[@]/%/...}" |
|
||||
sed 's|^k8s.io/kubernetes/vendor/||;s| k8s.io/kubernetes/vendor/| |' |
|
||||
grep -v " k8s.io/${PACKAGE}" |
|
||||
grep -v " k8s.io/${REPO}" |
|
||||
grep " k8s.io/" |
|
||||
grep -v -e "imports \(${RE}\)"
|
||||
)
|
||||
if [ -n "${FORBIDDEN}" ]; then
|
||||
echo "${PACKAGE} has a forbidden dependency:"
|
||||
echo "${REPO} has a forbidden dependency:"
|
||||
echo
|
||||
echo "${FORBIDDEN}" | sed 's/^/ /'
|
||||
echo
|
||||
return 1
|
||||
fi
|
||||
local TEST_FORBIDDEN=$(
|
||||
go list -f $'{{with $package := .ImportPath}}{{range $.TestImports}}{{$package}} imports {{.}}\n{{end}}{{end}}' ./vendor/k8s.io/${PACKAGE}/... |
|
||||
go list -f $'{{with $package := .ImportPath}}{{range $.TestImports}}{{$package}} imports {{.}}\n{{end}}{{end}}' "${PACKAGES[@]/%/...}" |
|
||||
sed 's|^k8s.io/kubernetes/vendor/||;s| k8s.io/kubernetes/vendor/| |' |
|
||||
grep -v " k8s.io/${PACKAGE}" |
|
||||
grep -v " k8s.io/${REPO}" |
|
||||
grep " k8s.io/" |
|
||||
grep -v -e "imports \(${RE}\)"
|
||||
)
|
||||
if [ -n "${TEST_FORBIDDEN}" ]; then
|
||||
echo "${PACKAGE} has a forbidden dependency in test code:"
|
||||
echo "${REPO} has a forbidden dependency in test code:"
|
||||
echo
|
||||
echo "${TEST_FORBIDDEN}" | sed 's/^/ /'
|
||||
echo
|
||||
@ -68,6 +75,8 @@ RC=0
|
||||
print_forbidden_imports apimachinery k8s.io/kube-openapi || RC=1
|
||||
print_forbidden_imports api k8s.io/apimachinery || RC=1
|
||||
print_forbidden_imports kube-gen k8s.io/apimachinery k8s.io/client-go k8s.io/gengo k8s.io/kube-openapi || RC=1
|
||||
print_forbidden_imports 'kube-gen/!(test)' k8s.io/gengo k8s.io/kube-openapi || RC=1
|
||||
print_forbidden_imports kube-gen/test k8s.io/apimachinery k8s.io/client-go || RC=1
|
||||
print_forbidden_imports client-go k8s.io/apimachinery k8s.io/api || RC=1
|
||||
print_forbidden_imports apiserver k8s.io/apimachinery k8s.io/client-go k8s.io/api k8s.io/kube-openapi || RC=1
|
||||
print_forbidden_imports metrics k8s.io/apimachinery k8s.io/client-go k8s.io/api || RC=1
|
||||
|
Loading…
Reference in New Issue
Block a user