2017-11-05 21:21:00 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Copyright 2017 The Kubernetes Authors.
|
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
set -o nounset
|
|
|
|
set -o pipefail
|
|
|
|
|
|
|
|
SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/..
|
|
|
|
|
2017-12-02 15:02:00 +00:00
|
|
|
DIFFROOT="${SCRIPT_ROOT}/internal"
|
2020-06-27 15:57:00 +00:00
|
|
|
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp"
|
2017-11-05 21:21:00 +00:00
|
|
|
|
|
|
|
cleanup() {
|
2020-06-27 15:57:00 +00:00
|
|
|
rm -rf "${TMP_DIFFROOT}"
|
2017-11-05 21:21:00 +00:00
|
|
|
}
|
|
|
|
trap "cleanup" EXIT SIGINT
|
|
|
|
|
|
|
|
cleanup
|
|
|
|
|
|
|
|
mkdir -p "${TMP_DIFFROOT}"
|
|
|
|
cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
|
|
|
|
|
|
|
|
"${SCRIPT_ROOT}/hack/update-codegen.sh"
|
|
|
|
echo "diffing ${DIFFROOT} against freshly generated codegen"
|
|
|
|
ret=0
|
2020-06-27 15:57:00 +00:00
|
|
|
diff -Naupr --no-dereference "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=1
|
|
|
|
|
2017-11-05 21:21:00 +00:00
|
|
|
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
|
2020-06-27 15:57:00 +00:00
|
|
|
if [[ $ret -eq 0 ]]; then
|
2017-11-05 21:21:00 +00:00
|
|
|
echo "${DIFFROOT} up to date."
|
|
|
|
else
|
|
|
|
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
|
|
|
|
exit 1
|
|
|
|
fi
|