mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-27 13:37:30 +00:00
Fix mungedocs for absolute paths
chdir into the parent of the docs directory, then walk docs. Fixes #11111
This commit is contained in:
parent
1b370599cc
commit
5c894b765b
@ -22,6 +22,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -127,6 +128,15 @@ func main() {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Split the root dir of "foo/docs" into "foo" and "docs". We
|
||||||
|
// chdir into "foo" and walk "docs" so the walk is always at a
|
||||||
|
// relative path.
|
||||||
|
stem, leaf := path.Split(strings.TrimRight(*rootDir, "/"))
|
||||||
|
if err := os.Chdir(stem); err != nil {
|
||||||
|
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
|
||||||
|
os.Exit(2)
|
||||||
|
}
|
||||||
|
|
||||||
fp := fileProcessor{
|
fp := fileProcessor{
|
||||||
munges: allMunges,
|
munges: allMunges,
|
||||||
verifyOnly: *verify,
|
verifyOnly: *verify,
|
||||||
@ -140,7 +150,7 @@ func main() {
|
|||||||
// changes needed.
|
// changes needed.
|
||||||
var changesNeeded bool
|
var changesNeeded bool
|
||||||
|
|
||||||
err := filepath.Walk(*rootDir, newWalkFunc(&fp, &changesNeeded))
|
err := filepath.Walk(leaf, newWalkFunc(&fp, &changesNeeded))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
|
fmt.Fprintf(os.Stderr, "ERROR: %v\n", err)
|
||||||
os.Exit(2)
|
os.Exit(2)
|
||||||
|
Loading…
Reference in New Issue
Block a user