|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Copyright 2024 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# This script is based on the following script: |
| 18 | +# release-tools/verify-vendor.sh |
| 19 | + |
| 20 | +if ! (set -x; env GO111MODULE=on go mod tidy); then |
| 21 | + echo "ERROR: vendor check failed." |
| 22 | + exit 1 |
| 23 | +elif [ "$(git status --porcelain -- go.mod go.sum | wc -l)" -gt 0 ]; then |
| 24 | + echo "ERROR: go module files *not* up-to-date, they did get modified by 'GO111MODULE=on go mod tidy':"; |
| 25 | + git diff --color=always -- go.mod go.sum | cat |
| 26 | + exit 1 |
| 27 | +else |
| 28 | + if ! (set -x; env GO111MODULE=on go mod vendor); then |
| 29 | + echo "ERROR: vendor check failed." |
| 30 | + exit 1 |
| 31 | + elif [ "$(git status --porcelain -- vendor | wc -l)" -gt 0 ]; then |
| 32 | + echo "ERROR: vendor directory *not* up-to-date, it did get modified by 'GO111MODULE=on go mod vendor':" |
| 33 | + git status -- vendor |
| 34 | + git diff --color=always -- vendor | cat |
| 35 | + exit 1 |
| 36 | + else |
| 37 | + echo "Go dependencies and vendor directory up-to-date." |
| 38 | + fi |
| 39 | +fi |
0 commit comments