github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/hack/make/validate-pkg (about) 1 #!/bin/bash 2 set -e 3 4 source "${MAKEDIR}/.validate" 5 6 IFS=$'\n' 7 files=( $(validate_diff --diff-filter=ACMR --name-only -- 'pkg/*.go' || true) ) 8 unset IFS 9 10 badFiles=() 11 for f in "${files[@]}"; do 12 IFS=$'\n' 13 badImports=( $(go list -e -f '{{ join .Deps "\n" }}' "$f" | sort -u | grep -vE '^github.com/docker/docker/pkg/' | grep -E '^github.com/docker/docker' || true) ) 14 unset IFS 15 16 for import in "${badImports[@]}"; do 17 badFiles+=( "$f imports $import" ) 18 done 19 done 20 21 if [ ${#badFiles[@]} -eq 0 ]; then 22 echo 'Congratulations! "./pkg/..." is safely isolated from internal code.' 23 else 24 { 25 echo 'These files import internal code: (either directly or indirectly)' 26 for f in "${badFiles[@]}"; do 27 echo " - $f" 28 done 29 echo 30 } >&2 31 false 32 fi