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
18f25dbe
Commit
18f25dbe
authored
Jan 08, 2019
by
Chris O'Haver
Committed by
GitHub
Jan 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
plugin/kubernetes: fix case preservation and add test (#2430)
* fix case preservation and add test * only fix case in k8s
parent
418edd2a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
4 deletions
+76
-4
plugin/kubernetes/handler.go
plugin/kubernetes/handler.go
+3
-2
plugin/kubernetes/handler_case_test.go
plugin/kubernetes/handler_case_test.go
+71
-0
plugin/normalize.go
plugin/normalize.go
+2
-2
No files found.
plugin/kubernetes/handler.go
View file @
18f25dbe
...
...
@@ -18,11 +18,12 @@ func (k Kubernetes) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.M
m
.
SetReply
(
r
)
m
.
Authoritative
=
true
zone
:=
plugin
.
Zones
(
k
.
Zones
)
.
Matches
(
state
.
Name
())
qname
:=
state
.
QName
()
zone
:=
plugin
.
Zones
(
k
.
Zones
)
.
Matches
(
qname
)
if
zone
==
""
{
return
plugin
.
NextOrFailure
(
k
.
Name
(),
k
.
Next
,
ctx
,
w
,
r
)
}
zone
=
qname
[
len
(
qname
)
-
len
(
zone
)
:
]
// maintain case of original query
state
.
Zone
=
zone
var
(
...
...
plugin/kubernetes/handler_case_test.go
0 → 100644
View file @
18f25dbe
package
kubernetes
import
(
"context"
"testing"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
"github.com/miekg/dns"
)
var
dnsPreserveCaseCases
=
[]
test
.
Case
{
// Negative response
{
Qname
:
"not-a-service.testns.svc.ClUsTeR.lOcAl."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeNameError
,
Ns
:
[]
dns
.
RR
{
test
.
SOA
(
"ClUsTeR.lOcAl. 30 IN SOA ns.dns.ClUsTeR.lOcAl. hostmaster.ClUsTeR.lOcAl. 1499347823 7200 1800 86400 60"
),
},
},
// A Service
{
Qname
:
"SvC1.TeStNs.SvC.cLuStEr.LoCaL."
,
Qtype
:
dns
.
TypeA
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
A
(
"SvC1.TeStNs.SvC.cLuStEr.LoCaL. 5 IN A 10.0.0.1"
),
},
},
// SRV Service
{
Qname
:
"_HtTp._TcP.sVc1.TeStNs.SvC.cLuStEr.LoCaL."
,
Qtype
:
dns
.
TypeSRV
,
Rcode
:
dns
.
RcodeSuccess
,
Answer
:
[]
dns
.
RR
{
test
.
SRV
(
"_HtTp._TcP.sVc1.TeStNs.SvC.cLuStEr.LoCaL. 5 IN SRV 0 100 80 svc1.testns.svc.cLuStEr.LoCaL."
),
},
Extra
:
[]
dns
.
RR
{
test
.
A
(
"svc1.testns.svc.cLuStEr.LoCaL. 5 IN A 10.0.0.1"
),
},
},
}
func
TestPreserveCase
(
t
*
testing
.
T
)
{
k
:=
New
([]
string
{
"cluster.local."
})
k
.
APIConn
=
&
APIConnServeTest
{}
k
.
opts
.
ignoreEmptyService
=
true
k
.
Next
=
test
.
NextHandler
(
dns
.
RcodeSuccess
,
nil
)
ctx
:=
context
.
TODO
()
for
i
,
tc
:=
range
dnsPreserveCaseCases
{
r
:=
tc
.
Msg
()
w
:=
dnstest
.
NewRecorder
(
&
test
.
ResponseWriter
{})
_
,
err
:=
k
.
ServeDNS
(
ctx
,
w
,
r
)
if
err
!=
tc
.
Error
{
t
.
Errorf
(
"Test %d expected no error, got %v"
,
i
,
err
)
return
}
if
tc
.
Error
!=
nil
{
continue
}
resp
:=
w
.
Msg
if
resp
==
nil
{
t
.
Fatalf
(
"Test %d, got nil message and no error for %q"
,
i
,
r
.
Question
[
0
]
.
Name
)
}
test
.
SortAndCheck
(
t
,
resp
,
tc
)
}
}
plugin/normalize.go
View file @
18f25dbe
...
...
@@ -15,8 +15,8 @@ import (
// Zones respresents a lists of zone names.
type
Zones
[]
string
// Matches checks i
s
qname is a subdomain of any of the zones in z. The match
// will return the most specific zones that matches
other
. The empty string
// Matches checks i
f
qname is a subdomain of any of the zones in z. The match
// will return the most specific zones that matches. The empty string
// signals a not found condition.
func
(
z
Zones
)
Matches
(
qname
string
)
string
{
zone
:=
""
...
...
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