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
cced1a4c
Commit
cced1a4c
authored
Jan 09, 2018
by
Miek Gieben
Committed by
GitHub
Jan 09, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pkg/fall: make Zero and Root vars not funcs (#1367)
These can be just vars. Think that was intended as well.
parent
a19ea63d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
51 additions
and
52 deletions
+51
-52
plugin/hosts/setup_test.go
plugin/hosts/setup_test.go
+11
-11
plugin/kubernetes/setup_test.go
plugin/kubernetes/setup_test.go
+24
-24
plugin/pkg/fall/fall.go
plugin/pkg/fall/fall.go
+3
-3
plugin/pkg/fall/fall_test.go
plugin/pkg/fall/fall_test.go
+2
-2
plugin/template/template_test.go
plugin/template/template_test.go
+11
-12
No files found.
plugin/hosts/setup_test.go
View file @
cced1a4c
...
...
@@ -19,43 +19,43 @@ func TestHostsParse(t *testing.T) {
{
`hosts
`
,
false
,
"/etc/hosts"
,
nil
,
fall
.
Zero
()
,
false
,
"/etc/hosts"
,
nil
,
fall
.
Zero
,
},
{
`hosts /tmp`
,
false
,
"/tmp"
,
nil
,
fall
.
Zero
()
,
false
,
"/tmp"
,
nil
,
fall
.
Zero
,
},
{
`hosts /etc/hosts miek.nl.`
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
},
fall
.
Zero
()
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
},
fall
.
Zero
,
},
{
`hosts /etc/hosts miek.nl. pun.gent.`
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
,
"pun.gent."
},
fall
.
Zero
()
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
,
"pun.gent."
},
fall
.
Zero
,
},
{
`hosts {
fallthrough
}`
,
false
,
"/etc/hosts"
,
nil
,
fall
.
Root
()
,
false
,
"/etc/hosts"
,
nil
,
fall
.
Root
,
},
{
`hosts /tmp {
fallthrough
}`
,
false
,
"/tmp"
,
nil
,
fall
.
Root
()
,
false
,
"/tmp"
,
nil
,
fall
.
Root
,
},
{
`hosts /etc/hosts miek.nl. {
fallthrough
}`
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
},
fall
.
Root
()
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
},
fall
.
Root
,
},
{
`hosts /etc/hosts miek.nl 10.0.0.9/8 {
fallthrough
}`
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
,
"10.in-addr.arpa."
},
fall
.
Root
()
,
false
,
"/etc/hosts"
,
[]
string
{
"miek.nl."
,
"10.in-addr.arpa."
},
fall
.
Root
,
},
}
...
...
@@ -105,7 +105,7 @@ func TestHostsInlineParse(t *testing.T) {
`example.org.`
,
},
},
fall
.
Root
()
,
fall
.
Root
,
},
{
`hosts highly_unlikely_to_exist_hosts_file example.org {
...
...
@@ -117,7 +117,7 @@ func TestHostsInlineParse(t *testing.T) {
`example.org.`
,
},
},
fall
.
Zero
()
,
fall
.
Zero
,
},
{
`hosts highly_unlikely_to_exist_hosts_file example.org {
...
...
@@ -126,7 +126,7 @@ func TestHostsInlineParse(t *testing.T) {
}`
,
true
,
map
[
string
][]
string
{},
fall
.
Root
()
,
fall
.
Root
,
},
}
...
...
plugin/kubernetes/setup_test.go
View file @
cced1a4c
...
...
@@ -34,7 +34,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -46,7 +46,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -59,7 +59,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -73,7 +73,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -87,7 +87,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -101,7 +101,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -115,7 +115,7 @@ func TestKubernetesParse(t *testing.T) {
30
*
time
.
Second
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -129,7 +129,7 @@ func TestKubernetesParse(t *testing.T) {
15
*
time
.
Minute
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -143,7 +143,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
"environment=prod"
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -157,7 +157,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
"application=nginx,environment in (production,qa,staging)"
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -175,7 +175,7 @@ func TestKubernetesParse(t *testing.T) {
15
*
time
.
Minute
,
"application=nginx,environment in (production,qa,staging)"
,
podModeDisabled
,
fall
.
Root
()
,
fall
.
Root
,
nil
,
},
// negative
...
...
@@ -190,7 +190,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -204,7 +204,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -218,7 +218,7 @@ func TestKubernetesParse(t *testing.T) {
0
*
time
.
Minute
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -232,7 +232,7 @@ func TestKubernetesParse(t *testing.T) {
0
*
time
.
Second
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -246,7 +246,7 @@ func TestKubernetesParse(t *testing.T) {
0
*
time
.
Second
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -260,7 +260,7 @@ func TestKubernetesParse(t *testing.T) {
0
*
time
.
Second
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
{
...
...
@@ -274,7 +274,7 @@ func TestKubernetesParse(t *testing.T) {
0
*
time
.
Second
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
// pods disabled
...
...
@@ -289,7 +289,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
// pods insecure
...
...
@@ -304,7 +304,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeInsecure
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
// pods verified
...
...
@@ -319,7 +319,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeVerified
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
// pods invalid
...
...
@@ -334,7 +334,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeVerified
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
// fallthrough with zones
...
...
@@ -364,7 +364,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
[]
string
{
"13.14.15.16:53"
},
},
// Invalid upstream
...
...
@@ -379,7 +379,7 @@ func TestKubernetesParse(t *testing.T) {
defaultResyncPeriod
,
""
,
podModeDisabled
,
fall
.
Zero
()
,
fall
.
Zero
,
nil
,
},
}
...
...
plugin/pkg/fall/fall.go
View file @
cced1a4c
...
...
@@ -28,7 +28,7 @@ func (f *F) setZones(zones []string) {
// SetZonesFromArgs sets zones in f to the passed value or to "." if the slice is empty.
func
(
f
*
F
)
SetZonesFromArgs
(
zones
[]
string
)
{
if
len
(
zones
)
==
0
{
f
.
setZones
(
Root
()
.
Zones
)
f
.
setZones
(
Root
.
Zones
)
return
}
f
.
setZones
(
zones
)
...
...
@@ -50,9 +50,9 @@ func (f F) Equal(g F) bool {
// Zero returns a zero valued F.
var
Zero
=
func
()
F
{
return
F
{[]
string
{}}
}
}
()
// Root returns F set to only ".".
var
Root
=
func
()
F
{
return
F
{[]
string
{
"."
}}
}
}
()
plugin/pkg/fall/fall_test.go
View file @
cced1a4c
...
...
@@ -23,7 +23,7 @@ func TestEqual(t *testing.T) {
func
TestZero
(
t
*
testing
.
T
)
{
var
f
F
if
!
f
.
Equal
(
Zero
()
)
{
if
!
f
.
Equal
(
Zero
)
{
t
.
Errorf
(
"F should be zero"
)
}
}
...
...
@@ -31,7 +31,7 @@ func TestZero(t *testing.T) {
func
TestSetZonesFromArgs
(
t
*
testing
.
T
)
{
var
f
F
f
.
SetZonesFromArgs
([]
string
{})
if
!
f
.
Equal
(
Root
()
)
{
if
!
f
.
Equal
(
Root
)
{
t
.
Errorf
(
"F should have the root zone"
)
}
...
...
plugin/template/template_test.go
View file @
cced1a4c
...
...
@@ -16,13 +16,12 @@ import (
)
func
TestHandler
(
t
*
testing
.
T
)
{
rcodeFallthrough
:=
3841
// reserved for private use, used to indicate a fallthrough
exampleDomainATemplate
:=
template
{
regex
:
[]
*
regexp
.
Regexp
{
regexp
.
MustCompile
(
"(^|[.])ip-10-(?P<b>[0-9]*)-(?P<c>[0-9]*)-(?P<d>[0-9]*)[.]example[.]$"
)},
answer
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"answer"
)
.
Parse
(
"{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
exampleDomainANSTemplate
:=
template
{
...
...
@@ -32,7 +31,7 @@ func TestHandler(t *testing.T) {
authority
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"authority"
)
.
Parse
(
"example. IN NS ns0.example.com."
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
exampleDomainMXTemplate
:=
template
{
...
...
@@ -41,7 +40,7 @@ func TestHandler(t *testing.T) {
additional
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"additional"
)
.
Parse
(
"{{ .Name }} 60 IN A 10.{{ .Group.b }}.{{ .Group.c }}.{{ .Group.d }}"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
invalidDomainTemplate
:=
template
{
...
...
@@ -50,7 +49,7 @@ func TestHandler(t *testing.T) {
answer
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"answer"
)
.
Parse
(
"invalid. 60 {{ .Class }} SOA a.invalid. b.invalid. (1 60 60 60 60)"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
rcodeServfailTemplate
:=
template
{
...
...
@@ -58,7 +57,7 @@ func TestHandler(t *testing.T) {
rcode
:
dns
.
RcodeServerFailure
,
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
brokenTemplate
:=
template
{
...
...
@@ -66,7 +65,7 @@ func TestHandler(t *testing.T) {
answer
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"answer"
)
.
Parse
(
"{{ .Name }} 60 IN TXT
\"
{{ index .Match 2 }}
\"
"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
nonRRTemplate
:=
template
{
...
...
@@ -74,7 +73,7 @@ func TestHandler(t *testing.T) {
answer
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"answer"
)
.
Parse
(
"{{ .Name }}"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
nonRRAdditionalTemplate
:=
template
{
...
...
@@ -82,7 +81,7 @@ func TestHandler(t *testing.T) {
additional
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"answer"
)
.
Parse
(
"{{ .Name }}"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
nonRRAuthoritativeTemplate
:=
template
{
...
...
@@ -90,7 +89,7 @@ func TestHandler(t *testing.T) {
authority
:
[]
*
gotmpl
.
Template
{
gotmpl
.
Must
(
gotmpl
.
New
(
"authority"
)
.
Parse
(
"{{ .Name }}"
))},
qclass
:
dns
.
ClassANY
,
qtype
:
dns
.
TypeANY
,
fall
:
fall
.
F
{
Zones
:
[]
string
{
"."
}}
,
fall
:
fall
.
Root
,
zones
:
[]
string
{
"."
},
}
...
...
@@ -297,7 +296,6 @@ func TestHandler(t *testing.T) {
// TestMultiSection verfies that a corefile with mutliple but different template sections works
func
TestMultiSection
(
t
*
testing
.
T
)
{
rcodeFallthrough
:=
3841
// reserved for private use, used to indicate a fallthrough
ctx
:=
context
.
TODO
()
multisectionConfig
:=
`
...
...
@@ -438,5 +436,6 @@ func TestMultiSection(t *testing.T) {
if
code
!=
dns
.
RcodeNameError
{
t
.
Fatalf
(
"TestMultiSection expected NXDOMAIN resolving something.example. IN MX, got %v, %v"
,
code
,
dns
.
RcodeToString
[
code
])
}
}
const
rcodeFallthrough
=
3841
// reserved for private use, used to indicate a fallthrough
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