Fix verify-godeps

This commit is contained in:
Tim Hockin 2016-05-01 00:00:36 -07:00
parent bfabdb05c5
commit 833770d9ac

View File

@ -48,7 +48,7 @@ if ! [[ ${KUBE_FORCE_VERIFY_CHECKS:-} =~ ^[yY]$ ]] && \
exit 0 exit 0
fi fi
# create a nice clean place to put our new godeps # Create a nice clean place to put our new godeps
_tmpdir="$(mktemp -d -t gopath.XXXXXX)" _tmpdir="$(mktemp -d -t gopath.XXXXXX)"
function cleanup { function cleanup {
echo "Removing ${_tmpdir}" echo "Removing ${_tmpdir}"
@ -56,39 +56,41 @@ function cleanup {
} }
trap cleanup EXIT trap cleanup EXIT
# build the godep tool # Copy the contents of the kube directory into the nice clean place
export GOPATH="${_tmpdir}"
go get -u github.com/tools/godep 2>/dev/null
GODEP="${_tmpdir}/bin/godep"
pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null
git checkout v53
"${GODEP}" go install
popd > /dev/null
# fill out that nice clean place with the kube godeps
echo "Starting to download all kubernetes godeps. This takes a while"
"${GODEP}" restore
echo "Download finished"
# copy the contents of your kube directory into the nice clean place
_kubetmp="${_tmpdir}/src/k8s.io" _kubetmp="${_tmpdir}/src/k8s.io"
mkdir -p "${_kubetmp}" mkdir -p "${_kubetmp}"
# should create ${_kubectmp}/kubernetes # should create ${_kubectmp}/kubernetes
git archive --format=tar --prefix=kubernetes/ $(git write-tree) | (cd "${_kubetmp}" && tar xf -) git archive --format=tar --prefix=kubernetes/ $(git write-tree) | (cd "${_kubetmp}" && tar xf -)
_kubetmp="${_kubetmp}/kubernetes" _kubetmp="${_kubetmp}/kubernetes"
# destroy godeps in our COPY of the kube tree # Do all our work in the new GOPATH
pushd "${_kubetmp}" > /dev/null export GOPATH="${_tmpdir}"
rm -rf ./Godeps cd "${_kubetmp}"
# for some reason the kube tree needs to be a git repo for the godep tool to run. Doesn't make sense # Build the godep tool
git init > /dev/null 2>&1 go get -u github.com/tools/godep 2>/dev/null
GODEP="${GOPATH}/bin/godep"
# recreate the Godeps using the nice clean set we just downloaded pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null
"${GODEP}" save ./... git checkout v53
"${GODEP}" go install
popd > /dev/null popd > /dev/null
# Fill out that nice clean place with the kube godeps
echo "Starting to download all kubernetes godeps. This takes a while"
"${GODEP}" restore
echo "Download finished"
# Destroy deps in the copy of the kube tree
rm -rf ./Godeps ./vendor
# For some reason the kube tree needs to be a git repo for the godep tool to
# run. Doesn't make sense.
git init > /dev/null 2>&1
# Recreate the Godeps using the nice clean set we just downloaded
"${GODEP}" save ./...
# Test for diffs
if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' --ignore-matching-lines='^\s*\"Comment\":' ${KUBE_ROOT}/Godeps/Godeps.json ${_kubetmp}/Godeps/Godeps.json)"; then if ! _out="$(diff -Naupr --ignore-matching-lines='^\s*\"GoVersion\":' --ignore-matching-lines='^\s*\"Comment\":' ${KUBE_ROOT}/Godeps/Godeps.json ${_kubetmp}/Godeps/Godeps.json)"; then
echo "Your Godeps.json is different:" echo "Your Godeps.json is different:"
echo "${_out}" echo "${_out}"