mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-01 17:29:00 +00:00
mungedocs should not assume upstream remote
The standard Git convention is "origin", not "upstream", so make it flexible in the scripts for those who are set up differently.
This commit is contained in:
@@ -36,6 +36,7 @@ var (
|
|||||||
verbose = flag.Bool("verbose", false, "On verification failure, emit pre-munge and post-munge versions.")
|
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.")
|
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.")
|
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.")
|
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
|
// "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.
|
relRoot = flag.String("repo-root", "..", `Appended to --root-dir to get the repository root.
|
||||||
@@ -199,7 +200,7 @@ func main() {
|
|||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
if *rootDir == "" {
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -216,14 +217,14 @@ func main() {
|
|||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
}
|
}
|
||||||
inJenkins = len(os.Getenv("JENKINS_HOME")) != 0
|
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 err != nil {
|
||||||
if inJenkins {
|
if inJenkins {
|
||||||
fmt.Fprintf(os.Stderr, "output: %s,\nERROR: %v\n", out, err)
|
fmt.Fprintf(os.Stderr, "output: %s,\nERROR: %v\n", out, err)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
} else {
|
} else {
|
||||||
fmt.Fprintf(os.Stdout, "output: %s,\nERROR: %v\n", out, err)
|
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 = ""
|
filesInLatestRelease = ""
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@@ -40,7 +40,7 @@ shopt -u dotglob
|
|||||||
kube::util::gen-analytics "${KUBE_ROOT}"
|
kube::util::gen-analytics "${KUBE_ROOT}"
|
||||||
|
|
||||||
mungedocs=$(kube::util::find-binary "mungedocs")
|
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
|
if [[ $ret -eq 1 ]]; then
|
||||||
echo "${KUBE_ROOT}/docs/ requires manual changes. See preceding errors."
|
echo "${KUBE_ROOT}/docs/ requires manual changes. See preceding errors."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -49,7 +49,7 @@ elif [[ $ret -gt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [[ $ret -eq 1 ]]; then
|
||||||
echo "${KUBE_ROOT}/examples/ requires manual changes. See preceding errors."
|
echo "${KUBE_ROOT}/examples/ requires manual changes. See preceding errors."
|
||||||
exit 1
|
exit 1
|
||||||
@@ -58,7 +58,8 @@ elif [[ $ret -gt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
"${mungedocs}" "--skip-munges=unversioned-warning,analytics" \
|
"${mungedocs}" "--upstream=${KUBE_GIT_UPSTREAM}" \
|
||||||
|
"--skip-munges=unversioned-warning,analytics" \
|
||||||
"--norecurse" \
|
"--norecurse" \
|
||||||
"--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
|
"--root-dir=${KUBE_ROOT}/" && ret=0 || ret=$?
|
||||||
if [[ $ret -eq 1 ]]; then
|
if [[ $ret -eq 1 ]]; then
|
||||||
|
@@ -37,7 +37,7 @@ EXAMPLEROOT="${KUBE_ROOT}/examples/"
|
|||||||
# mungedocs --verify can (and should) be run on the real docs, otherwise their
|
# 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.
|
# links will be distorted. --verify means that it will not make changes.
|
||||||
# --verbose gives us output we can use for a diff.
|
# --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
|
if [[ $ret -eq 1 ]]; then
|
||||||
echo "${DOCROOT} is out of date. Please run hack/update-generated-docs.sh"
|
echo "${DOCROOT} is out of date. Please run hack/update-generated-docs.sh"
|
||||||
exit 1
|
exit 1
|
||||||
@@ -47,7 +47,7 @@ if [[ $ret -gt 1 ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
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
|
if [[ $ret -eq 1 ]]; then
|
||||||
echo "${EXAMPLEROOT} is out of date. Please run hack/update-generated-docs.sh"
|
echo "${EXAMPLEROOT} is out of date. Please run hack/update-generated-docs.sh"
|
||||||
exit 1
|
exit 1
|
||||||
|
@@ -40,6 +40,8 @@ source "${KUBE_ROOT}/hack/lib/version.sh"
|
|||||||
source "${KUBE_ROOT}/hack/lib/golang.sh"
|
source "${KUBE_ROOT}/hack/lib/golang.sh"
|
||||||
source "${KUBE_ROOT}/hack/lib/etcd.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)"
|
KUBE_OUTPUT_HOSTBIN="${KUBE_OUTPUT_BINPATH}/$(kube::util::host_platform)"
|
||||||
|
|
||||||
# emulates "readlink -f" which is not available on BSD (OS X).
|
# 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.
|
# Follow links until there are no more links to follow.
|
||||||
while readlink "$path"; do
|
while readlink "$path"; do
|
||||||
path="$(readlink $path)"
|
path="$(readlink $path)"
|
||||||
done
|
done
|
||||||
# Convert to canonical path.
|
# Convert to canonical path.
|
||||||
path=$(cd "$(dirname "${path}")" && pwd -P)
|
path=$(cd "$(dirname "${path}")" && pwd -P)
|
||||||
echo "$path"
|
echo "$path"
|
||||||
|
Reference in New Issue
Block a user