Skip to content

Commit d28a665

Browse files
committed
Merge pull request kubernetes#11452 from thockin/docs-munge-headerlines
Munge headerlines
2 parents ce6b137 + 33f1862 commit d28a665

File tree

214 files changed

+745
-29
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

214 files changed

+745
-29
lines changed

cmd/mungedocs/headers.go

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2015 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"fmt"
21+
"regexp"
22+
"strings"
23+
)
24+
25+
var headerRegex = regexp.MustCompile(`^(#+)\s*(.*)$`)
26+
var whitespaceRegex = regexp.MustCompile(`^\s*$`)
27+
28+
func fixHeaderLines(fileBytes []byte) []byte {
29+
lines := splitLines(fileBytes)
30+
out := []string{}
31+
for i := range lines {
32+
matches := headerRegex.FindStringSubmatch(lines[i])
33+
if matches == nil {
34+
out = append(out, lines[i])
35+
continue
36+
}
37+
if i > 0 && !whitespaceRegex.Match([]byte(out[len(out)-1])) {
38+
out = append(out, "")
39+
}
40+
out = append(out, fmt.Sprintf("%s %s", matches[1], matches[2]))
41+
if i+1 < len(lines) && !whitespaceRegex.Match([]byte(lines[i+1])) {
42+
out = append(out, "")
43+
}
44+
}
45+
final := strings.Join(out, "\n")
46+
// Preserve the end of the file.
47+
if len(fileBytes) > 0 && fileBytes[len(fileBytes)-1] == '\n' {
48+
final += "\n"
49+
}
50+
return []byte(final)
51+
}
52+
53+
// Header lines need whitespace around them and after the #s.
54+
func checkHeaderLines(filePath string, fileBytes []byte) ([]byte, error) {
55+
fbs := splitByPreformatted(fileBytes)
56+
fbs = append([]fileBlock{{false, []byte{}}}, fbs...)
57+
fbs = append(fbs, fileBlock{false, []byte{}})
58+
59+
for i := range fbs {
60+
block := &fbs[i]
61+
if block.preformatted {
62+
continue
63+
}
64+
block.data = fixHeaderLines(block.data)
65+
}
66+
output := []byte{}
67+
for _, block := range fbs {
68+
output = append(output, block.data...)
69+
}
70+
return output, nil
71+
}

cmd/mungedocs/headers_test.go

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*
2+
Copyright 2015 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package main
18+
19+
import (
20+
"testing"
21+
22+
"github.com/stretchr/testify/assert"
23+
)
24+
25+
func TestHeaderLines(t *testing.T) {
26+
var cases = []struct {
27+
in string
28+
out string
29+
}{
30+
{"", ""},
31+
{
32+
"# ok",
33+
"# ok",
34+
},
35+
{
36+
"## ok",
37+
"## ok",
38+
},
39+
{
40+
"##### ok",
41+
"##### ok",
42+
},
43+
{
44+
"##fix",
45+
"## fix",
46+
},
47+
{
48+
"foo\n\n##fix\n\nbar",
49+
"foo\n\n## fix\n\nbar",
50+
},
51+
{
52+
"foo\n##fix\nbar",
53+
"foo\n\n## fix\n\nbar",
54+
},
55+
{
56+
"foo\n```\n##fix\n```\nbar",
57+
"foo\n```\n##fix\n```\nbar",
58+
},
59+
{
60+
"foo\n#fix1\n##fix2\nbar",
61+
"foo\n\n# fix1\n\n## fix2\n\nbar",
62+
},
63+
}
64+
for i, c := range cases {
65+
actual, err := checkHeaderLines("filename.md", []byte(c.in))
66+
assert.NoError(t, err)
67+
if string(actual) != c.out {
68+
t.Errorf("case[%d]: expected %q got %q", i, c.out, string(actual))
69+
}
70+
}
71+
}

cmd/mungedocs/mungedocs.go

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ Examples:
4848
{"table-of-contents", updateTOC},
4949
{"check-links", checkLinks},
5050
{"blank-lines-surround-preformatted", checkPreformatted},
51+
{"header-lines", checkHeaderLines},
5152
{"unversioned-warning", updateUnversionedWarning},
5253
{"analytics", checkAnalytics},
5354
{"kubectl-dash-f", checkKubectlFileTargets},

docs/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Kubernetes Documentation: releases.k8s.io/HEAD
3435

3536
* The [User's guide](user-guide/README.md) is for anyone who wants to run programs and

docs/admin/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Kubernetes Cluster Admin Guide
3435

3536
The cluster admin guide is for anyone creating or administering a Kubernetes cluster.
@@ -72,6 +73,7 @@ If you are modifying an existing guide which uses Salt, this document explains [
7273
project.](salt.md).
7374

7475
## Upgrading a cluster
76+
7577
[Upgrading a cluster](cluster-management.md).
7678

7779
## Managing nodes

docs/admin/accessing-the-api.md

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Configuring APIserver ports
3435

3536
This document describes what ports the kubernetes apiserver
@@ -42,6 +43,7 @@ in [Accessing the cluster](../user-guide/accessing-the-cluster.md).
4243

4344

4445
## Ports and IPs Served On
46+
4547
The Kubernetes API is served by the Kubernetes APIServer process. Typically,
4648
there is one of these running on a single kubernetes-master node.
4749

@@ -93,6 +95,7 @@ variety of uses cases:
9395
setup time. Kubelets use cert-based auth, while kube-proxy uses token-based auth.
9496

9597
## Expected changes
98+
9699
- Policy will limit the actions kubelets can do via the authed port.
97100
- Scheduler and Controller-manager will use the Secure Port too. They
98101
will then be able to run on different machines than the apiserver.

docs/admin/admission-controllers.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Admission Controllers
3435

3536
**Table of Contents**

docs/admin/authentication.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Authentication Plugins
3435

3536
Kubernetes uses client certificates, tokens, or http basic auth to authenticate users for API calls.

docs/admin/authorization.md

+3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Authorization Plugins
3435

3536

@@ -53,6 +54,7 @@ The following implementations are available, and are selected by flag:
5354
`ABAC` allows for user-configured authorization policy. ABAC stands for Attribute-Based Access Control.
5455

5556
## ABAC Mode
57+
5658
### Request Attributes
5759

5860
A request has 4 attributes that can be considered for authorization:
@@ -105,6 +107,7 @@ To permit any user to do something, write a policy with the user property unset.
105107
To permit an action Policy with an unset namespace applies regardless of namespace.
106108

107109
### Examples
110+
108111
1. Alice can do anything: `{"user":"alice"}`
109112
2. Kubelet can read any pods: `{"user":"kubelet", "resource": "pods", "readonly": true}`
110113
3. Kubelet can read and write events: `{"user":"kubelet", "resource": "events"}`

docs/admin/cluster-components.md

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Kubernetes Cluster Admin Guide: Cluster Components
3435

3536
This document outlines the various binary components that need to run to
@@ -92,6 +93,7 @@ These controllers include:
9293
selects a node for them to run on.
9394

9495
### addons
96+
9597
Addons are pods and services that implement cluster features. They don't run on
9698
the master VM, but currently the default setup scripts that make the API calls
9799
to create these pods and services does run on the master VM. See:

docs/admin/cluster-large.md

+3
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,11 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Kubernetes Large Cluster
3435

3536
## Support
37+
3638
At v1.0, Kubernetes supports clusters up to 100 nodes with 30 pods per node and 1-2 container per pod (as defined in the [1.0 roadmap](../../docs/roadmap.md#reliability-and-performance)).
3739

3840
## Setup
@@ -59,6 +61,7 @@ To avoid running into cloud provider quota issues, when creating a cluster with
5961
* Gating the setup script so that it brings up new node VMs in smaller batches with waits in between, because some cloud providers rate limit the creation of VMs.
6062

6163
### Addon Resources
64+
6265
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)).
6366

6467
For example:

docs/admin/cluster-management.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Cluster Management
3435

3536
This doc is in progress.

docs/admin/cluster-troubleshooting.md

+6
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# Cluster Troubleshooting
35+
3436
This doc is about cluster troubleshooting; we assume you have already ruled out your application as the root cause of the
3537
problem you are experiencing. See
3638
the [application troubleshooting guide](../user-guide/application-troubleshooting.md) for tips on application debugging.
3739
You may also visit [troubleshooting document](../troubleshooting.md) for more information.
3840

3941
## Listing your cluster
42+
4043
The first thing to debug in your cluster is if your nodes are all registered correctly.
4144

4245
Run
@@ -48,15 +51,18 @@ kubectl get nodes
4851
And verify that all of the nodes you expect to see are present and that they are all in the ```Ready``` state.
4952

5053
## Looking at logs
54+
5155
For now, digging deeper into the cluster requires logging into the relevant machines. Here are the locations
5256
of the relevant log files. (note that on systemd-based systems, you may need to use ```journalctl``` instead)
5357

5458
### Master
59+
5560
* /var/log/kube-apiserver.log - API Server, responsible for serving the API
5661
* /var/log/kube-scheduler.log - Scheduler, responsible for making scheduling decisions
5762
* /var/log/kube-controller-manager.log - Controller that manages replication controllers
5863

5964
### Worker Nodes
65+
6066
* /var/log/kubelet.log - Kubelet, responsible for running containers on the node
6167
* /var/log/kube-proxy.log - Kube Proxy, responsible for service load balancing
6268

docs/admin/dns.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Documentation for other releases can be found at
3030
<!-- END STRIP_FOR_RELEASE -->
3131

3232
<!-- END MUNGE: UNVERSIONED_WARNING -->
33+
3334
# DNS Integration with Kubernetes
3435

3536
As of kubernetes 0.8, DNS is offered as a [cluster add-on](../../cluster/addons/README.md).

0 commit comments

Comments
 (0)