Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
f77c6e55
Commit
f77c6e55
authored
Jan 31, 2020
by
Miek Gieben
Committed by
GitHub
Jan 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
presubmit: test README.md sections (#3644)
Automatically submitted.
parent
510f2c50
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
62 additions
and
2 deletions
+62
-2
plugin.md
plugin.md
+1
-1
plugin/cancel/README.md
plugin/cancel/README.md
+2
-0
plugin/k8s_external/README.md
plugin/k8s_external/README.md
+1
-1
plugin/rewrite/README.md
plugin/rewrite/README.md
+2
-0
plugin/secondary/README.md
plugin/secondary/README.md
+2
-0
plugin/transfer/README.md
plugin/transfer/README.md
+4
-0
test/readme_test.go
test/readme_test.go
+50
-0
No files found.
plugin.md
View file @
f77c6e55
...
@@ -75,7 +75,7 @@ Each plugin should have a README.md explaining what the plugin does and how it i
...
@@ -75,7 +75,7 @@ Each plugin should have a README.md explaining what the plugin does and how it i
file should have the following layout:
file should have the following layout:
*
Title: use the plugin's name
*
Title: use the plugin's name
*
Subsection titled: "Name
d
"
*
Subsection titled: "Name"
with
*PLUGIN*
- one line description.
with
*PLUGIN*
- one line description.
*
Subsection titled: "Description" has a longer description.
*
Subsection titled: "Description" has a longer description.
*
Subsection titled: "Syntax", syntax and supported directives.
*
Subsection titled: "Syntax", syntax and supported directives.
...
...
plugin/cancel/README.md
View file @
f77c6e55
...
@@ -16,6 +16,8 @@ A plugin interested in the cancellation status should call `plugin.Done()` on th
...
@@ -16,6 +16,8 @@ A plugin interested in the cancellation status should call `plugin.Done()` on th
context was canceled due to a timeout the plugin should not write anything back to the client and
context was canceled due to a timeout the plugin should not write anything back to the client and
return a value indicating CoreDNS should not either; a zero return value should suffice for that.
return a value indicating CoreDNS should not either; a zero return value should suffice for that.
## Syntax
~~~
txt
~~~
txt
cancel [TIMEOUT]
cancel [TIMEOUT]
~~~
~~~
...
...
plugin/k8s_external/README.md
View file @
f77c6e55
...
@@ -57,7 +57,7 @@ k8s_external [ZONE...] {
...
@@ -57,7 +57,7 @@ k8s_external [ZONE...] {
*
**APEX**
is the name (DNS label) to use for the apex records; it defaults to
`dns`
.
*
**APEX**
is the name (DNS label) to use for the apex records; it defaults to
`dns`
.
*
`ttl`
allows you to set a custom
**TTL**
for responses. The default is 5 (seconds).
*
`ttl`
allows you to set a custom
**TTL**
for responses. The default is 5 (seconds).
# Examples
#
#
Examples
Enable names under
`example.org`
to be resolved to in-cluster DNS addresses.
Enable names under
`example.org`
to be resolved to in-cluster DNS addresses.
...
...
plugin/rewrite/README.md
View file @
f77c6e55
...
@@ -37,6 +37,8 @@ will behave as follows:
...
@@ -37,6 +37,8 @@ will behave as follows:
*
`continue`
will continue applying the next rule in the rule list.
*
`continue`
will continue applying the next rule in the rule list.
*
`stop`
will consider the current rule the last rule and will not continue. The default behaviour is
`stop`
*
`stop`
will consider the current rule the last rule and will not continue. The default behaviour is
`stop`
## Examples
### Name Field Rewrites
### Name Field Rewrites
The
`rewrite`
plugin offers the ability to match the name in the question section of
The
`rewrite`
plugin offers the ability to match the name in the question section of
...
...
plugin/secondary/README.md
View file @
f77c6e55
...
@@ -10,6 +10,8 @@ With *secondary* you can transfer (via AXFR) a zone from another server. The ret
...
@@ -10,6 +10,8 @@ With *secondary* you can transfer (via AXFR) a zone from another server. The ret
*not committed*
to disk (a violation of the RFC). This means restarting CoreDNS will cause it to
*not committed*
to disk (a violation of the RFC). This means restarting CoreDNS will cause it to
retrieve all secondary zones.
retrieve all secondary zones.
## Syntax
~~~
~~~
secondary [ZONES...]
secondary [ZONES...]
~~~
~~~
...
...
plugin/transfer/README.md
View file @
f77c6e55
...
@@ -29,3 +29,7 @@ transfer [ZONE...] {
...
@@ -29,3 +29,7 @@ transfer [ZONE...] {
*
`to `
**HOST...**
The hosts
*transfer*
will transfer to. Use
`*`
to permit
*
`to `
**HOST...**
The hosts
*transfer*
will transfer to. Use
`*`
to permit
transfers to all hosts.
transfers to all hosts.
## Examples
TODO
test/readme_test.go
View file @
f77c6e55
...
@@ -2,10 +2,12 @@ package test
...
@@ -2,10 +2,12 @@ package test
import
(
import
(
"bufio"
"bufio"
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
"strconv"
"strconv"
"strings"
"testing"
"testing"
"github.com/coredns/coredns/core/dnsserver"
"github.com/coredns/coredns/core/dnsserver"
...
@@ -39,6 +41,9 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM=
...
@@ -39,6 +41,9 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM=
// # check-this-please
// # check-this-please
// }
// }
// ~~~
// ~~~
//
// While we're at it - we also check the README.md itself. It should at least have the sections:
// Name, Description, Syntax and Examples. See plugin.md for more details.
func
TestReadme
(
t
*
testing
.
T
)
{
func
TestReadme
(
t
*
testing
.
T
)
{
port
:=
30053
port
:=
30053
caddy
.
Quiet
=
true
caddy
.
Quiet
=
true
...
@@ -59,6 +64,10 @@ func TestReadme(t *testing.T) {
...
@@ -59,6 +64,10 @@ func TestReadme(t *testing.T) {
readme
:=
filepath
.
Join
(
middle
,
d
.
Name
())
readme
:=
filepath
.
Join
(
middle
,
d
.
Name
())
readme
=
filepath
.
Join
(
readme
,
"README.md"
)
readme
=
filepath
.
Join
(
readme
,
"README.md"
)
if
err
:=
sectionsFromReadme
(
readme
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
inputs
,
err
:=
corefileFromReadme
(
readme
)
inputs
,
err
:=
corefileFromReadme
(
readme
)
if
err
!=
nil
{
if
err
!=
nil
{
continue
continue
...
@@ -118,6 +127,47 @@ func corefileFromReadme(readme string) ([]*Input, error) {
...
@@ -118,6 +127,47 @@ func corefileFromReadme(readme string) ([]*Input, error) {
return
input
,
nil
return
input
,
nil
}
}
// sectionsFromReadme returns an error if the readme doesn't contains all
// mandatory sections. The check is basic, as we match each line, this mostly
// works, because markdown is such a simple format.
// We want: Name, Description, Syntax, Examples - in this order.
func
sectionsFromReadme
(
readme
string
)
error
{
f
,
err
:=
os
.
Open
(
readme
)
if
err
!=
nil
{
return
nil
// don't error when we can read the file
}
defer
f
.
Close
()
section
:=
0
s
:=
bufio
.
NewScanner
(
f
)
for
s
.
Scan
()
{
line
:=
s
.
Text
()
switch
section
{
case
0
:
if
strings
.
HasPrefix
(
line
,
"## Name"
)
{
section
++
}
case
1
:
if
strings
.
HasPrefix
(
line
,
"## Description"
)
{
section
++
}
case
2
:
if
strings
.
HasPrefix
(
line
,
"## Syntax"
)
{
section
++
}
case
3
:
if
strings
.
HasPrefix
(
line
,
"## Examples"
)
{
section
++
}
}
}
if
section
!=
4
{
return
fmt
.
Errorf
(
"Sections incomplete or ordered wrong: %q, want (at least): Name, Descripion, Syntax and Examples"
,
readme
)
}
return
nil
}
func
create
(
c
map
[
string
]
string
)
{
func
create
(
c
map
[
string
]
string
)
{
for
name
,
content
:=
range
c
{
for
name
,
content
:=
range
c
{
ioutil
.
WriteFile
(
name
,
[]
byte
(
content
),
0644
)
ioutil
.
WriteFile
(
name
,
[]
byte
(
content
),
0644
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment