Skip to content

Commit

Permalink
Merge pull request kubernetes#11314 from mikedanese/mungdocs-error
Browse files Browse the repository at this point in the history
mungedoc should exit 1 when manual changes are required.
  • Loading branch information
erictune committed Jul 15, 2015
2 parents c76a1f8 + d4d99de commit 97d13c2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
10 changes: 7 additions & 3 deletions cmd/mungedocs/mungedocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,16 +187,20 @@ func main() {
// - If verify is true: exit 0 if no changes needed, exit 1 if changes
// needed.
// - If verify is false: exit 0 if changes successfully made or no
// changes needed.
// changes needed, exit 1 if manual changes are needed.
var changesNeeded bool

err := filepath.Walk(leaf, newWalkFunc(&fp, &changesNeeded))
if err != nil {
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
os.Exit(2)
}
if changesNeeded && *verify {
fmt.Fprintf(os.Stderr, "FAIL: changes needed but not made due to --verify\n")
if changesNeeded {
if *verify {
fmt.Fprintf(os.Stderr, "FAIL: changes needed but not made due to --verify\n")
} else {
fmt.Fprintf(os.Stderr, "FAIL: some manual changes are still required.\n")
}
os.Exit(1)
}
}
10 changes: 4 additions & 6 deletions hack/run-gendocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,20 @@ kube::util::gen-doc "${genman}" "${KUBE_ROOT}" "docs/man/man1"
kube::util::gen-doc "${genbashcomp}" "${KUBE_ROOT}" "contrib/completions/bash/"
kube::util::gen-analytics "${KUBE_ROOT}"

"${mungedocs}" "--root-dir=${KUBE_ROOT}/docs/"
ret=$?
"${mungedocs}" "--root-dir=${KUBE_ROOT}/docs/" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${KUBE_ROOT}/docs/ requires manual changes. See preceeding errors."
exit 1
elif [[ $ret -eq 2 ]]; then
elif [[ $ret -gt 1 ]]; then
echo "Error running mungedocs."
exit 1
fi

"${mungedocs}" "--root-dir=${KUBE_ROOT}/examples/"
ret=$?
"${mungedocs}" "--root-dir=${KUBE_ROOT}/examples/" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${KUBE_ROOT}/examples/ requires manual changes. See preceeding errors."
exit 1
elif [[ $ret -eq 2 ]]; then
elif [[ $ret -gt 1 ]]; then
echo "Error running mungedocs."
exit 1
fi
Expand Down
16 changes: 6 additions & 10 deletions hack/verify-gendocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,22 @@ cp -a "${DOCROOT}" "${TMP_DOCROOT}"

# mungedocs --verify can (and should) be run on the real docs, otherwise their
# links will be distorted. --verify means that it will not make changes.
"${mungedocs}" "--verify=true" "--root-dir=${DOCROOT}"
ret=$?
"${mungedocs}" "--verify=true" "--root-dir=${DOCROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${DOCROOT} is out of date. Please run hack/run-gendocs.sh"
exit 1
fi
if [[ $ret -eq 2 ]]; then
if [[ $ret -gt 1 ]]; then
echo "Error running mungedocs"
exit 1
fi

"${mungedocs}" "--verify=true" "--root-dir=${EXAMPLEROOT}"
ret=$?
"${mungedocs}" "--verify=true" "--root-dir=${EXAMPLEROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${EXAMPLEROOT} is out of date. Please run hack/run-gendocs.sh"
exit 1
fi
if [[ $ret -eq 2 ]]; then
if [[ $ret -gt 1 ]]; then
echo "Error running mungedocs"
exit 1
fi
Expand All @@ -75,8 +73,7 @@ kube::util::gen-doc "${genman}" "${_tmp}" "docs/man/man1/"
kube::util::gen-doc "${gendocs}" "${_tmp}" "docs/user-guide/kubectl/" '###### Auto generated by spf13/cobra'

echo "diffing ${DOCROOT} against freshly generated docs"
ret=0
diff -Naupr "${DOCROOT}" "${TMP_DOCROOT}" || ret=$?
diff -Naupr "${DOCROOT}" "${TMP_DOCROOT}" && ret=0 || ret=$?
rm -rf "${_tmp}"
needsanalytics=($(kube::util::gen-analytics "${KUBE_ROOT}" 1))
if [[ ${#needsanalytics[@]} -ne 0 ]]; then
Expand All @@ -96,8 +93,7 @@ COMPROOT="${KUBE_ROOT}/contrib/completions"
TMP_COMPROOT="${KUBE_ROOT}/contrib/completions_tmp"
cp -a "${COMPROOT}" "${TMP_COMPROOT}"
kube::util::gen-doc "${genbashcomp}" "${TMP_COMPROOT}" "bash/"
ret=0
diff -Naupr "${COMPROOT}" "${TMP_COMPROOT}" || ret=$?
diff -Naupr "${COMPROOT}" "${TMP_COMPROOT}" && ret=0 || ret=$?
rm -rf ${TMP_COMPROOT}
if [ $ret -eq 0 ]
then
Expand Down

0 comments on commit 97d13c2

Please sign in to comment.