diff --git a/cmd/mungedocs/mungedocs.go b/cmd/mungedocs/mungedocs.go index 87e8641361b..5f41e02a045 100644 --- a/cmd/mungedocs/mungedocs.go +++ b/cmd/mungedocs/mungedocs.go @@ -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. @@ -199,7 +200,7 @@ func main() { flag.Parse() if *rootDir == "" { - fmt.Fprintf(os.Stderr, "usage: %s [--help] [--verify] [--norecurse] --root-dir [--skip-munges=] \n", flag.Arg(0)) + fmt.Fprintf(os.Stderr, "usage: %s [--help] [--verify] [--norecurse] --root-dir [--skip-munges=] [--upstream=] \n", flag.Arg(0)) os.Exit(1) } @@ -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 { diff --git a/hack/after-build/update-generated-docs.sh b/hack/after-build/update-generated-docs.sh index c74c7e3ba4f..735c83737c3 100755 --- a/hack/after-build/update-generated-docs.sh +++ b/hack/after-build/update-generated-docs.sh @@ -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 @@ -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 @@ -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 diff --git a/hack/after-build/verify-generated-docs.sh b/hack/after-build/verify-generated-docs.sh index 8087772e9bf..bc6714aa7e1 100755 --- a/hack/after-build/verify-generated-docs.sh +++ b/hack/after-build/verify-generated-docs.sh @@ -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 @@ -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 diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 9fa47ca2dfe..eaacbdae9e4 100644 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -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). @@ -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"