@@ -112,23 +112,18 @@ function diff_version_deps {
112
112
function print_diff_version_deps {
113
113
jq -r '
114
114
to_entries
115
- | map("Error: version mismatch: \(.key) is \(.value.has), but \(.value.wants) expected")
115
+ | map("Version mismatch: \(.key) is \(.value.has), but \(.value.wants) expected")
116
116
| join("\n")
117
- | halt_error(1)
118
117
'
119
118
}
120
119
121
120
# Compares versions of dependencies in the supplied go.mod to
122
121
# makes sure they are in line with the ones declared in
123
- # k8s.io/kubernetes module and prints the result .
124
- function compare_mod_versions_or_fail {
122
+ # k8s.io/kubernetes module.
123
+ function compare_mod_versions_with_k8s_deps {
125
124
gomod_file=" ${1} "
126
- echo " Verifying dependency versions in ${gomod_file} against ${k8s_gomod} "
127
125
deps=" $( list_deps ${gomod_file} ) "
128
-
129
- diff_version_deps <( echo " ${deps} " ) <( echo " ${k8s_deps} " ) \
130
- | print_diff_version_deps " ${gomod_file} " 1>&2 \
131
- || { echo ; exit 1 ; }
126
+ diff_version_deps <( echo " ${deps} " ) <( echo " ${k8s_deps} " )
132
127
}
133
128
134
129
function gomod_filepath_for {
@@ -149,9 +144,17 @@ for dir in "${MODULE_DIRS[@]}"; do
149
144
exit 1
150
145
fi
151
146
152
- compare_mod_versions_or_fail " ${dir} /go.mod"
147
+ gomod_file=" ${dir} /go.mod"
148
+ echo " Verifying dependency versions in ${gomod_file} against ${k8s_gomod} "
149
+
150
+ diff=" $( compare_mod_versions_with_k8s_deps ${dir} /go.mod) "
151
+ if [[ -n " ${diff} " ]]; then
152
+ echo " ${diff} " | print_diff_version_deps 1>&2
153
+ echo " ${diff} " | grep -q " k8s.io/" && {
154
+ echo " Error: dependencies from '*k8s.io/*' must be in line with ${k8s_gomod} " 1>&2
155
+ exit 1
156
+ } || true
157
+ echo " Continuing because no fatal errors found"
158
+ fi
153
159
)
154
160
done
155
-
156
- compare_mod_versions_or_fail " $( gomod_filepath_for github.com/kcp-dev/client-go) "
157
- compare_mod_versions_or_fail " $( gomod_filepath_for github.com/kcp-dev/apimachinery/v2) "
0 commit comments