New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
hack/verify-staging-imports.sh: print actual dependencies #40659
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,13 +23,39 @@ source "${KUBE_ROOT}/hack/lib/init.sh" | |
|
||
kube::golang::setup_env | ||
|
||
function print_forbidden_imports () { | ||
set -o errexit # this was unset by || | ||
local PACKAGE="$1" | ||
shift | ||
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 | ||
return 0 | ||
} | ||
|
||
for dep in $(ls -1 ${KUBE_ROOT}/staging/src/k8s.io/); do | ||
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 | ||
echo "${dep} has a cyclical dependency" | ||
exit 1 | ||
fi | ||
done | ||
RC=0 | ||
print_forbidden_imports apimachinery k8s.io/ || RC=1 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this ended up a lot better. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If at any point you expect There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. good point. thanks. Those details of shell code... |
||
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 | ||
echo 'file has "// import "k8s.io/kubernetes/"' | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this pick up the first argument?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shift
above removes itThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of the shift on line 28