Skip to content

Commit 786b594

Browse files
committed
Merge pull request kubernetes#11400 from lavalamp/munger
Add absolute path link checking to munger
2 parents 6bf3582 + 98eeadb commit 786b594

File tree

25 files changed

+70
-53
lines changed

25 files changed

+70
-53
lines changed

cmd/mungedocs/links.go

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ func checkLinks(filePath string, fileBytes []byte) ([]byte, error) {
6363
return in
6464
}
6565

66-
if u.Host != "" {
67-
// We only care about relative links.
66+
if u.Host != "" && u.Host != "github.com" {
67+
// We only care about relative links and links within github.
6868
return in
6969
}
7070

@@ -78,6 +78,14 @@ func checkLinks(filePath string, fileBytes []byte) ([]byte, error) {
7878
)
7979
}
8080
u.Path = newPath
81+
if strings.HasPrefix(u.Path, "/") {
82+
u.Host = "github.com"
83+
u.Scheme = "https"
84+
} else {
85+
// Remove host and scheme from relative paths
86+
u.Host = ""
87+
u.Scheme = ""
88+
}
8189
// Make the visible text show the absolute path if it's
8290
// not nested in or beneath the current directory.
8391
if strings.HasPrefix(u.Path, "..") {
@@ -95,7 +103,7 @@ func checkLinks(filePath string, fileBytes []byte) ([]byte, error) {
95103
}
96104
// If the current visible text is trying to be a file name, use
97105
// the correct file name.
98-
if (strings.Contains(visibleText, ".md") || strings.Contains(visibleText, "/")) && !strings.ContainsAny(visibleText, ` '"`+"`") {
106+
if strings.HasSuffix(visibleText, ".md") && !strings.ContainsAny(visibleText, ` '"`+"`") {
99107
visibleText = suggestedVisibleText
100108
}
101109

@@ -129,13 +137,25 @@ func cleanPath(dirPath, linkPath string) string {
129137

130138
func checkPath(filePath, linkPath string) (newPath string, ok bool) {
131139
dir := path.Dir(filePath)
132-
if strings.HasPrefix(linkPath, "/") {
133-
if !strings.HasPrefix(linkPath, "/GoogleCloudPlatform") {
134-
// Any absolute paths that aren't relative to github.com are wrong.
135-
// Try to fix.
136-
linkPath = linkPath[1:]
140+
absFilePrefixes := []string{
141+
"/GoogleCloudPlatform/kubernetes/blob/master/",
142+
"/GoogleCloudPlatform/kubernetes/tree/master/",
143+
}
144+
for _, prefix := range absFilePrefixes {
145+
if strings.HasPrefix(linkPath, prefix) {
146+
linkPath = strings.TrimPrefix(linkPath, prefix)
147+
// Now linkPath is relative to the root of the repo. The below
148+
// loop that adds ../ at the beginning of the path should find
149+
// the right path.
150+
break
137151
}
138152
}
153+
if strings.HasPrefix(linkPath, "/") {
154+
// These links might go to e.g. the github issues page, or a
155+
// file at a particular revision, or another github project
156+
// entirely.
157+
return linkPath, true
158+
}
139159
linkPath = cleanPath(dir, linkPath)
140160

141161
// Fast exit if the link is already correct.
@@ -174,7 +194,7 @@ func checkPath(filePath, linkPath string) (newPath string, ok bool) {
174194
if info.IsDir() {
175195
return newPath + "/", true
176196
}
177-
return newPath, true
197+
return cleanPath(dir, newPath), true
178198
}
179199
newPath = path.Join("..", newPath)
180200
}

docs/admin/accessing-the-api.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ variety of uses cases:
8989
- Scheduler and Controller-manager will use the Secure Port too. They
9090
will then be able to run on different machines than the apiserver.
9191
- A general mechanism will be provided for [giving credentials to
92-
pods](
93-
https://github.com/GoogleCloudPlatform/kubernetes/issues/1907).
92+
pods](https://github.com/GoogleCloudPlatform/kubernetes/issues/1907).
9493
- Clients, like kubectl, will all support token-based auth, and the
9594
Localhost will no longer be needed, and will not be the default.
9695
However, the localhost port may continue to be an option for

docs/admin/cluster-large.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ certainly want the docs that go with that version.</h1>
2323
# Kubernetes Large Cluster
2424

2525
## Support
26-
At v1.0, Kubernetes supports clusters up to 100 nodes with 30-50 pods per node and 1-2 container per pod (as defined in the [1.0 roadmap](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/roadmap.md#reliability-and-performance)).
26+
At v1.0, Kubernetes supports clusters up to 100 nodes with 30-50 pods per node and 1-2 container per pod (as defined in the [1.0 roadmap](../../docs/roadmap.md#reliability-and-performance)).
2727

2828
## Setup
2929

30-
Normally the number of nodes in a cluster is controlled by the the value `NUM_MINIONS` in the platform-specific `config-default.sh` file (for example, see [GCE's `config-default.sh`](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/gce/config-default.sh)).
30+
Normally the number of nodes in a cluster is controlled by the the value `NUM_MINIONS` in the platform-specific `config-default.sh` file (for example, see [GCE's `config-default.sh`](../../cluster/gce/config-default.sh)).
3131

3232
Simply changing that value to something very large, however, may cause the setup script to fail for many cloud providers. A GCE deployment, for example, will run in to quota issues and fail to bring the cluster up.
3333

@@ -49,7 +49,7 @@ To avoid running into cloud provider quota issues, when creating a cluster with
4949
* Gating the setup script so that it brings up new node VMs in smaller batches with waits in between, because some cloud providers limit the number of VMs you can create during a given period.
5050

5151
### Addon Resources
52-
To prevent memory leaks or other resource issues in [cluster addons](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/cluster/addons/) from consuming all the resources available on a node, Kubernetes sets resource limits on addon containers to limit the CPU and Memory resources they can consume (See PR [#10653](https://github.com/GoogleCloudPlatform/kubernetes/pull/10653/files) and [#10778](https://github.com/GoogleCloudPlatform/kubernetes/pull/10778/files)).
52+
To prevent memory leaks or other resource issues in [cluster addons](../../cluster/addons/) from consuming all the resources available on a node, Kubernetes sets resource limits on addon containers to limit the CPU and Memory resources they can consume (See PR [#10653](https://github.com/GoogleCloudPlatform/kubernetes/pull/10653/files) and [#10778](https://github.com/GoogleCloudPlatform/kubernetes/pull/10778/files)).
5353

5454
For example:
5555
```YAML

docs/admin/high-availability.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ certainly want the docs that go with that version.</h1>
3535
## Introduction
3636
This document describes how to build a high-availability (HA) Kubernetes cluster. This is a fairly advanced topic.
3737
Users who merely want to experiment with Kubernetes are encouraged to use configurations that are simpler to set up such as
38-
the simple [Docker based single node cluster instructions](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/getting-started-guides/docker.md),
38+
the simple [Docker based single node cluster instructions](../../docs/getting-started-guides/docker.md),
3939
or try [Google Container Engine](https://cloud.google.com/container-engine/) for hosted Kubernetes.
4040

4141
Also, at this time high availability support for Kubernetes is not continuously tested in our end-to-end (e2e) testing. We will

docs/design/event_compression.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ Each binary that generates events (for example, ```kubelet```) should keep track
3535
Event compression should be best effort (not guaranteed). Meaning, in the worst case, ```n``` identical (minus timestamp) events may still result in ```n``` event entries.
3636

3737
## Design
38-
Instead of a single Timestamp, each event object [contains](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/api/types.go#L1111) the following fields:
38+
Instead of a single Timestamp, each event object [contains](../../pkg/api/types.go#L1111) the following fields:
3939
* ```FirstTimestamp util.Time```
4040
* The date/time of the first occurrence of the event.
4141
* ```LastTimestamp util.Time```
@@ -47,7 +47,7 @@ Instead of a single Timestamp, each event object [contains](https://github.com/G
4747

4848
Each binary that generates events:
4949
* Maintains a historical record of previously generated events:
50-
* Implemented with ["Least Recently Used Cache"](https://github.com/golang/groupcache/blob/master/lru/lru.go) in [```pkg/client/record/events_cache.go```](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/pkg/client/record/events_cache.go).
50+
* Implemented with ["Least Recently Used Cache"](https://github.com/golang/groupcache/blob/master/lru/lru.go) in [```pkg/client/record/events_cache.go```](../../pkg/client/record/events_cache.go).
5151
* The key in the cache is generated from the event object minus timestamps/count/transient fields, specifically the following events fields are used to construct a unique key for an event:
5252
* ```event.Source.Component```
5353
* ```event.Source.Host```
@@ -59,7 +59,7 @@ Each binary that generates events:
5959
* ```event.Reason```
6060
* ```event.Message```
6161
* The LRU cache is capped at 4096 events. That means if a component (e.g. kubelet) runs for a long period of time and generates tons of unique events, the previously generated events cache will not grow unchecked in memory. Instead, after 4096 unique events are generated, the oldest events are evicted from the cache.
62-
* When an event is generated, the previously generated events cache is checked (see [```pkg/client/record/event.go```](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/pkg/client/record/event.go)).
62+
* When an event is generated, the previously generated events cache is checked (see [```pkg/client/record/event.go```](../../pkg/client/record/event.go)).
6363
* If the key for the new event matches the key for a previously generated event (meaning all of the above fields match between the new event and some previously generated event), then the event is considered to be a duplicate and the existing event entry is updated in etcd:
6464
* The new PUT (update) event API is called to update the existing event entry in etcd with the new last seen timestamp and count.
6565
* The event is also updated in the previously generated events cache with an incremented count, updated last seen timestamp, name, and new resource version (all required to issue a future event update).

docs/devel/cli-roadmap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ certainly want the docs that go with that version.</h1>
2323
# Kubernetes CLI/Configuration Roadmap
2424

2525
See also issues with the following labels:
26-
* [area/config-deployment](https://github.com/GoogleCloudPlatform/kubernetes/labels/area%2Fconfig-deployment)
27-
* [component/CLI](https://github.com/GoogleCloudPlatform/kubernetes/labels/component%2FCLI)
28-
* [component/client](https://github.com/GoogleCloudPlatform/kubernetes/labels/component%2Fclient)
26+
* [area/app-config-deployment](https://github.com/GoogleCloudPlatform/kubernetes/labels/area/app-config-deployment)
27+
* [component/CLI](https://github.com/GoogleCloudPlatform/kubernetes/labels/component/CLI)
28+
* [component/client](https://github.com/GoogleCloudPlatform/kubernetes/labels/component/client)
2929

3030
1. Create services before other objects, or at least before objects that depend upon them. Namespace-relative DNS mitigates this some, but most users are still using service environment variables. [#1768](https://github.com/GoogleCloudPlatform/kubernetes/issues/1768)
3131
1. Finish rolling update [#1353](https://github.com/GoogleCloudPlatform/kubernetes/issues/1353)

docs/devel/client-libraries.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ certainly want the docs that go with that version.</h1>
2323
## kubernetes API client libraries
2424

2525
### Supported
26-
* [Go](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/pkg/client)
26+
* [Go](../../pkg/client/)
2727

2828
### User Contributed
2929
*Note: Libraries provided by outside parties are supported by their authors, not the core Kubernetes team*

docs/getting-started-guides/aws.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,16 @@ export KUBERNETES_PROVIDER=aws; wget -q -O - https://get.k8s.io | bash
5050
export KUBERNETES_PROVIDER=aws; curl -sS https://get.k8s.io | bash
5151
```
5252

53-
NOTE: This script calls [cluster/kube-up.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/kube-up.sh)
54-
which in turn calls [cluster/aws/util.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/aws/util.sh)
55-
using [cluster/aws/config-default.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/aws/config-default.sh).
53+
NOTE: This script calls [cluster/kube-up.sh](../../cluster/kube-up.sh)
54+
which in turn calls [cluster/aws/util.sh](../../cluster/aws/util.sh)
55+
using [cluster/aws/config-default.sh](../../cluster/aws/config-default.sh).
5656

5757
This process takes about 5 to 10 minutes. Once the cluster is up, the IP addresses of your master and node(s) will be printed,
5858
as well as information about the default services running in the cluster (monitoring, logging, dns). User credentials and security
5959
tokens are written in `~/.kube/kubeconfig`, they will be necessary to use the CLI or the HTTP Basic Auth.
6060

6161
By default, the script will provision a new VPC and a 4 node k8s cluster in us-west-2a (Oregon) with `t2.micro` instances running on Ubuntu.
62-
You can override the variables defined in [config-default.sh](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/cluster/aws/config-default.sh) to change this behavior as follows:
62+
You can override the variables defined in [config-default.sh](../../cluster/aws/config-default.sh) to change this behavior as follows:
6363

6464
```bash
6565
export KUBE_AWS_ZONE=eu-west-1c
@@ -95,10 +95,10 @@ export PATH=<path/to/kubernetes-directory>/platforms/darwin/amd64:$PATH
9595
export PATH=<path/to/kubernetes-directory>/platforms/linux/amd64:$PATH
9696
```
9797

98-
An up-to-date documentation page for this tool is available here: [kubectl manual](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubectl.md)
98+
An up-to-date documentation page for this tool is available here: [kubectl manual](../../docs/user-guide/kubectl/kubectl.md)
9999

100100
By default, `kubectl` will use the `kubeconfig` file generated during the cluster startup for authenticating against the API.
101-
For more information, please read [kubeconfig files](https://github.com/GoogleCloudPlatform/kubernetes/blob/master/docs/kubeconfig-file.md)
101+
For more information, please read [kubeconfig files](../../docs/user-guide/kubeconfig-file.md)
102102

103103
### Examples
104104
See [a simple nginx example](../../docs/user-guide/simple-nginx.md) to try out your new cluster.
@@ -116,7 +116,7 @@ cluster/kube-down.sh
116116
```
117117

118118
## Further reading
119-
Please see the [Kubernetes docs](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/docs) for more details on administering
119+
Please see the [Kubernetes docs](../../docs/) for more details on administering
120120
and using a Kubernetes cluster.
121121

122122

docs/getting-started-guides/cloudstack.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ This [Ansible](http://ansibleworks.com) playbook deploys Kubernetes on a CloudSt
4848
$ sudo pip install ansible
4949
$ sudo pip install cs
5050

51-
[_cs_](http://github.com/exoscale/cs) is a python module for the CloudStack API.
51+
[_cs_](https://github.com/exoscale/cs) is a python module for the CloudStack API.
5252

5353
Set your CloudStack endpoint, API keys and HTTP method used.
5454

docs/getting-started-guides/locally.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ hack/local-up-cluster.sh
150150
One or more of the kubernetes daemons might've crashed. Tail the logs of each in /tmp.
151151

152152
#### The pods fail to connect to the services by host names
153-
The local-up-cluster.sh script doesn't start a DNS service. Similar situation can be found [here](https://github.com/GoogleCloudPlatform/kubernetes/issues/6667). You can start a manually. Related documents can be found [here](https://github.com/GoogleCloudPlatform/kubernetes/tree/master/cluster/addons/dns#how-do-i-configure-it)
153+
The local-up-cluster.sh script doesn't start a DNS service. Similar situation can be found [here](https://github.com/GoogleCloudPlatform/kubernetes/issues/6667). You can start a manually. Related documents can be found [here](../../cluster/addons/dns/#how-do-i-configure-it)
154154

155155

156156
<!-- BEGIN MUNGE: GENERATED_ANALYTICS -->

0 commit comments

Comments
 (0)