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

mungedocs should not assume upstream remote #24666

Merged
merged 1 commit into from
May 6, 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
7 changes: 4 additions & 3 deletions cmd/mungedocs/mungedocs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ var (
verbose = flag.Bool("verbose", false, "On verification failure, emit pre-munge and post-munge versions.")
verify = flag.Bool("verify", false, "Exit with status 1 if files would have needed changes but do not change.")
norecurse = flag.Bool("norecurse", false, "Only process the files of --root-dir.")
upstream = flag.String("upstream", "upstream", "The name of the upstream Git remote to pull from")
rootDir = flag.String("root-dir", "", "Root directory containing documents to be processed.")
// "repo-root" seems like a dumb name, this is the relative path (from rootDir) to get to the repoRoot
relRoot = flag.String("repo-root", "..", `Appended to --root-dir to get the repository root.
Expand Down Expand Up @@ -199,7 +200,7 @@ func main() {
flag.Parse()

if *rootDir == "" {
fmt.Fprintf(os.Stderr, "usage: %s [--help] [--verify] [--norecurse] --root-dir [--skip-munges=<skip list>] <docs root>\n", flag.Arg(0))
fmt.Fprintf(os.Stderr, "usage: %s [--help] [--verify] [--norecurse] --root-dir [--skip-munges=<skip list>] [--upstream=<git remote>] <docs root>\n", flag.Arg(0))
os.Exit(1)
}

Expand All @@ -216,14 +217,14 @@ func main() {
os.Exit(2)
}
inJenkins = len(os.Getenv("JENKINS_HOME")) != 0
out, err := exec.Command("git", "ls-tree", "-r", "--name-only", fmt.Sprintf("%s/%s", "upstream", latestReleaseBranch), absRootDir).CombinedOutput()
out, err := exec.Command("git", "ls-tree", "-r", "--name-only", fmt.Sprintf("%s/%s", *upstream, latestReleaseBranch), absRootDir).CombinedOutput()
if err != nil {
if inJenkins {
fmt.Fprintf(os.Stderr, "output: %s,\nERROR: %v\n", out, err)
os.Exit(2)
} else {
fmt.Fprintf(os.Stdout, "output: %s,\nERROR: %v\n", out, err)
fmt.Fprintf(os.Stdout, "`git ls-tree -r --name-only upstream/%s failed. We'll ignore this error locally, but Jenkins may pick an error. Munger uses the output of this command to determine in unversioned warning, if it should add a link to the doc in release branch.\n", latestReleaseBranch)
fmt.Fprintf(os.Stdout, "`git ls-tree -r --name-only %s/%s failed. We'll ignore this error locally, but Jenkins may pick an error. Munger uses the output of this command to determine in unversioned warning, if it should add a link to the doc in release branch.\n", *upstream, latestReleaseBranch)
filesInLatestRelease = ""
}
} else {
Expand Down
7 changes: 4 additions & 3 deletions hack/after-build/update-generated-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ shopt -u dotglob
kube::util::gen-analytics "${KUBE_ROOT}"

mungedocs=$(kube::util::find-binary "mungedocs")
"${mungedocs}" "--root-dir=${KUBE_ROOT}/docs/" && ret=0 || ret=$?
"${mungedocs}" "--upstream=${KUBE_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 @@ -49,7 +49,7 @@ elif [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--root-dir=${KUBE_ROOT}/examples/" && ret=0 || ret=$?
"${mungedocs}" "--upstream=${KUBE_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 @@ -58,7 +58,8 @@ elif [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--skip-munges=unversioned-warning,analytics" \
"${mungedocs}" "--upstream=${KUBE_GIT_UPSTREAM}" \
"--skip-munges=unversioned-warning,analytics" \
"--norecurse" \
"--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
Expand Down
4 changes: 2 additions & 2 deletions hack/after-build/verify-generated-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,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" "--root-dir=${DOCROOT}" && ret=0 || ret=$?
"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${DOCROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${DOCROOT} is out of date. Please run hack/update-generated-docs.sh"
exit 1
Expand All @@ -47,7 +47,7 @@ if [[ $ret -gt 1 ]]; then
exit 1
fi

"${mungedocs}" "--verify=true" "--verbose=true" "--root-dir=${EXAMPLEROOT}" && ret=0 || ret=$?
"${mungedocs}" "--verify=true" "--verbose=true" "--upstream=${KUBE_GIT_UPSTREAM}" "--root-dir=${EXAMPLEROOT}" && ret=0 || ret=$?
if [[ $ret -eq 1 ]]; then
echo "${EXAMPLEROOT} is out of date. Please run hack/update-generated-docs.sh"
exit 1
Expand Down
4 changes: 3 additions & 1 deletion hack/lib/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ 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)"

# emulates "readlink -f" which is not available on BSD (OS X).
Expand All @@ -48,7 +50,7 @@ function readlinkdashf {
# Follow links until there are no more links to follow.
while readlink "$path"; do
path="$(readlink $path)"
done
done
# Convert to canonical path.
path=$(cd "$(dirname "${path}")" && pwd -P)
echo "$path"
Expand Down