Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
| ... | ... |
@@ -8,6 +8,17 @@ source "${SCRIPTDIR}/.validate"
|
| 8 | 8 |
tidy_files=('go.mod' 'go.sum')
|
| 9 | 9 |
vendor_files=("${tidy_files[@]}" 'vendor/')
|
| 10 | 10 |
|
| 11 |
+validate_vendor_files_exist() {
|
|
| 12 |
+ local file |
|
| 13 |
+ for file in "${vendor_files[@]}"; do
|
|
| 14 |
+ if [ ! -e "$file" ]; then |
|
| 15 |
+ echo >&2 "ERROR: required file '$file' does not exist" |
|
| 16 |
+ return 1 |
|
| 17 |
+ fi |
|
| 18 |
+ done |
|
| 19 |
+ return 0 |
|
| 20 |
+} |
|
| 21 |
+ |
|
| 11 | 22 |
validate_vendor_tidy() {
|
| 12 | 23 |
# run mod tidy |
| 13 | 24 |
./hack/vendor.sh tidy |
| ... | ... |
@@ -37,6 +48,16 @@ validate_vendor_license() {
|
| 37 | 37 |
done < <(awk '/^# /{ print $2 }' vendor/modules.txt)
|
| 38 | 38 |
} |
| 39 | 39 |
|
| 40 |
+# First check the required files exist as git diff will not report missing files. |
|
| 41 |
+if ! validate_vendor_files_exist; then |
|
| 42 |
+ {
|
|
| 43 |
+ echo 'FAIL: Vendoring was not performed correctly!' |
|
| 44 |
+ echo |
|
| 45 |
+ echo 'Please revendor with hack/vendor.sh' |
|
| 46 |
+ } >&2 |
|
| 47 |
+ exit 1 |
|
| 48 |
+fi |
|
| 49 |
+ |
|
| 40 | 50 |
if validate_vendor_tidy && validate_vendor_diff && validate_vendor_license; then |
| 41 | 51 |
echo >&2 'PASS: Vendoring has been performed correctly!' |
| 42 | 52 |
else |