34
34
kube::golang::verify_go_version
35
35
kube::util::require-jq
36
36
37
- outdated=$( go list -m -json all | jq -r '
37
+ case " ${1:- } " in
38
+ " --all" )
39
+ echo " Checking all dependencies"
40
+ filter=' '
41
+ ;;
42
+ " -a" )
43
+ echo " Checking all dependencies"
44
+ filter=' '
45
+ ;;
46
+ " " )
47
+ # by default, skip checking golang.org/x/... dependencies... we pin to levels that match our go version for those
48
+ echo " Skipping golang.org/x/... dependencies, pass --all to include"
49
+ filter=' select(.Path | startswith("golang.org/x/") | not) |'
50
+ ;;
51
+ * )
52
+ kube::log::error " Unrecognized arg: ${1} "
53
+ exit 1
54
+ ;;
55
+ esac
56
+
57
+ outdated=$( go list -m -json all | jq -r "
38
58
select(.Replace.Version != null) |
39
59
select(.Version != .Replace.Version) |
40
- "\(.Path)
60
+ ${filter}
61
+ select(.Path) |
62
+ \" \(.Path)
41
63
pinned: \(.Replace.Version)
42
64
preferred: \(.Version)
43
- hack/pin-dependency.sh \(.Path) \(.Version)"
44
- ' )
65
+ hack/pin-dependency.sh \(.Path) \(.Version)\ "
66
+ " )
45
67
if [[ -n " ${outdated} " ]]; then
46
68
echo " These modules are pinned to versions different than the minimal preferred version."
47
- echo " That means that without require directives, a different version would be selected."
48
- echo " The command to switch to the minimal preferred version is listed for each module."
69
+ echo " That means that without replace directives, a different version would be selected,"
70
+ echo " which breaks consumers of our published modules."
71
+ echo " 1. Use hack/pin-dependency.sh to switch to the preferred version for each module"
72
+ echo " 2. Run hack/update-vendor.sh to rebuild the vendor directory"
73
+ echo " 3. Run hack/lint-dependencies.sh to verify no additional changes are required"
49
74
echo " "
50
75
echo " ${outdated} "
51
76
fi
@@ -55,13 +80,13 @@ unused=$(comm -23 \
55
80
<( go list -m -json all | jq -r .Path | sort) )
56
81
if [[ -n " ${unused} " ]]; then
57
82
echo " "
58
- echo " Pinned module versions that aren't actually used:"
83
+ echo " Use the given commands to remove pinned module versions that aren't actually used:"
59
84
echo " ${unused} " | xargs -L 1 echo ' GO111MODULE=on go mod edit -dropreplace'
60
85
fi
61
86
62
87
if [[ -n " ${unused}${outdated} " ]]; then
63
88
exit 1
64
89
fi
65
90
66
- echo " All pinned dependencies match their preferred version."
91
+ echo " All pinned versions of checked dependencies match their preferred version."
67
92
exit 0
0 commit comments