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
_kubetmp="${_tmpdir}/src/k8s.io"
mkdir -p "${_kubetmp}"
# should create ${_kubectmp}/kubernetes
git archive --format=tar --prefix=kubernetes/ $(git write-tree) | (cd "${_kubetmp}" && tar xf -)
_kubetmp="${_kubetmp}/kubernetes"
# Do all our work in the new GOPATH
export GOPATH="${_tmpdir}" export GOPATH="${_tmpdir}"
cd "${_kubetmp}"
# Build the godep tool
go get -u github.com/tools/godep 2>/dev/null go get -u github.com/tools/godep 2>/dev/null
GODEP="${_tmpdir}/bin/godep" GODEP="${GOPATH}/bin/godep"
pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null pushd "${GOPATH}/src/github.com/tools/godep" > /dev/null
git checkout v53 git checkout v53
"${GODEP}" go install "${GODEP}" go install
popd > /dev/null popd > /dev/null
# fill out that nice clean place with the kube godeps # Fill out that nice clean place with the kube godeps
echo "Starting to download all kubernetes godeps. This takes a while" echo "Starting to download all kubernetes godeps. This takes a while"
"${GODEP}" restore "${GODEP}" restore
echo "Download finished" echo "Download finished"
# copy the contents of your kube directory into the nice clean place # Destroy deps in the copy of the kube tree
_kubetmp="${_tmpdir}/src/k8s.io" rm -rf ./Godeps ./vendor
mkdir -p "${_kubetmp}"
#should create ${_kubectmp}/kubernetes
git archive --format=tar --prefix=kubernetes/ $(git write-tree) | (cd "${_kubetmp}" && tar xf -)
_kubetmp="${_kubetmp}/kubernetes"
# destroy godeps in our COPY of the kube tree # For some reason the kube tree needs to be a git repo for the godep tool to
pushd "${_kubetmp}" > /dev/null # run. Doesn't make sense.
rm -rf ./Godeps git init > /dev/null 2>&1
# for some reason the kube tree needs to be a git repo for the godep tool to run. Doesn't make sense # Recreate the Godeps using the nice clean set we just downloaded
git init > /dev/null 2>&1 "${GODEP}" save ./...
# recreate the Godeps using the nice clean set we just downloaded
"${GODEP}" save ./...
popd > /dev/null
# 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}"