Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move KUBE_GIT_UPSTREAM out of init.sh and into *-munge-docs.sh. #27808

Merged
merged 1 commit into from
Jul 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ source "${KUBE_ROOT}/hack/lib/version.sh"
source "${KUBE_ROOT}/hack/lib/golang.sh"
source "${KUBE_ROOT}/hack/lib/etcd.sh"

KUBE_GIT_UPSTREAM="${KUBE_GIT_UPSTREAM:-upstream}"

KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::util::host_platform)"

# This emulates "readlink -f" which is not available on MacOS X.
Expand Down
14 changes: 11 additions & 3 deletions hack/update-munge-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"

git_upstream=$(kube::util::git_upstream_remote_name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest continuing to use the env variable, but defaulting it to this value if it's not set.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we can get rid ourselves of another unused global, I think we're making the world a better place. If you grep through hack/*, KUBE_GIT_UPSTREAM is set once in init and referred to only in the -munge- scripts and documented exactly nowhere. My inclination here is to simplify and reduce. But if you feel strongly, I can put it back.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah, the part I was objecting to wasn't clobbering the env var so much as it's no longer possible to set the option to a custom value at all. If you don't think that's ever a reasonable use case then I'm fine with this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like we're really overloaded with globals in the scripts and it's not clear to me how or if they are used at all. Given it isn't documented anywhere I'm inclined to beg forgiveness here and scrub it. We can always add it back (with documentation).

: ${git_upstream:="upstream"}

kube::golang::setup_env

"${KUBE_ROOT}/hack/build-go.sh" \
Expand All @@ -31,7 +34,10 @@ kube::util::ensure-temp-dir
kube::util::gen-analytics "${KUBE_ROOT}"

mungedocs=$(kube::util::find-binary "mungedocs")
"${mungedocs}" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${KUBE_ROOT}/docs/" && ret=0 || ret=$?

"${mungedocs}" "--upstream=${git_upstream}" "--root-dir=${KUBE_ROOT}/docs/" \
&& ret=0 || ret=$?

if [[ $ret -eq 1 ]]; then
echo "${KUBE_ROOT}/docs/ requires manual changes. See preceding errors."
exit 1
Expand All @@ -40,7 +46,9 @@ elif [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${KUBE_ROOT}/examples/" && ret=0 || ret=$?
"${mungedocs}" "--upstream=${git_upstream}" \
"--root-dir=${KUBE_ROOT}/examples/" && ret=0 || ret=$?

if [[ $ret -eq 1 ]]; then
echo "${KUBE_ROOT}/examples/ requires manual changes. See preceding errors."
exit 1
Expand All @@ -49,7 +57,7 @@ elif [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--upstream=${KUBE_GIT_UPSTREAM}" \
"${mungedocs}" "--upstream=${git_upstream}" \
"--skip-munges=unversioned-warning,analytics" \
"--norecurse" \
"--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
Expand Down
7 changes: 5 additions & 2 deletions hack/verify-munge-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set -o pipefail
KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
source "${KUBE_ROOT}/hack/lib/init.sh"

git_upstream=$(kube::util::git_upstream_remote_name)
: ${git_upstream:="upstream"}

kube::golang::setup_env

"${KUBE_ROOT}/hack/build-go.sh" \
Expand All @@ -35,7 +38,7 @@ EXAMPLEROOT="${KUBE_ROOT}/examples/"
# 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.
# --verbose gives us output we can use for a diff.
"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${DOCROOT}" && ret=0 || ret=$?
"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${git_upstream}" "--root-dir=${DOCROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${DOCROOT} is out of date. Please run hack/update-munge-docs.sh"
exit 1
Expand All @@ -45,7 +48,7 @@ if [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${EXAMPLEROOT}" && ret=0 || ret=$?
"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${git_upstream}" "--root-dir=${EXAMPLEROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${EXAMPLEROOT} is out of date. Please run hack/update-munge-docs.sh"
exit 1
Expand Down