Doc generation should remove old doc files

Right now, our doc generation scripts notice if you make changes and
don't regen docs, don't include new docs, etc.  But they miss it if your
changes should have REMOVED a doc.  Both kubectl-apiversion and
kubectl-clusterinfo should have been removed, but weren't.

This patch starts tracking all generated doc files and will cause
problems if files should be removed and aren't.
This commit is contained in:
Eric Paris
2015-04-13 12:14:08 -04:00
parent 7464575b17
commit 26149bd83d
6 changed files with 102 additions and 10 deletions

View File

@@ -118,3 +118,31 @@ kube::util::wait-for-jobs() {
done
return ${fail}
}
# takes a binary to run $1 and then copies the results to $2
kube::util::gen-doc() {
local cmd="$1"
local dest="$2"
# remove all old generated file from the destination
for file in $(cat "${dest}/.files_generated" 2>/dev/null); do
set +e
rm "${dest}/${file}"
set -e
done
# We do this in a tmpdir in case the dest has other non-autogenned files
# We don't want to include them in the list of gen'd files
local tmpdir="${KUBE_ROOT}/doc_tmp"
mkdir "${tmpdir}"
# generate the new files
${cmd} "${tmpdir}"
# create the list of generated files
ls "${tmpdir}" | sort > "${tmpdir}/.files_generated"
# put the new generated file into the destination
find "${tmpdir}" -exec rsync -pt {} "${dest}" \; >/dev/null
#cleanup
rm -rf "${tmpdir}"
}
# ex: ts=2 sw=2 et filetype=sh