replace reviewdog fully by golangci-lint (#6139)
Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
parent
6d3db023fe
commit
8c489bd400
17 changed files with 125 additions and 146 deletions
25
.github/workflows/reviewdog.yml
vendored
25
.github/workflows/reviewdog.yml
vendored
|
@ -1,25 +0,0 @@
|
||||||
name: Reviewdog
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
|
|
||||||
permissions: read-all
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
gofmt:
|
|
||||||
name: Go Fmt
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
|
|
||||||
- run: find . -not -path '*/\.git/*' -type f -name '*.go' -exec gofmt -s -w {} \+
|
|
||||||
- uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e
|
|
||||||
|
|
||||||
whitespace:
|
|
||||||
name: Whitespace
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8
|
|
||||||
- run: find . -not -path '*/\.git/*' -type f -not -name '*.go' -exec sed -i 's/[[:space:]]\{1,\}$//' {} \+
|
|
||||||
- uses: reviewdog/action-suggester@8f83d27e749053b2029600995c115026a010408e
|
|
|
@ -9,3 +9,4 @@ linters:
|
||||||
- typecheck
|
- typecheck
|
||||||
- whitespace
|
- whitespace
|
||||||
- unused
|
- unused
|
||||||
|
- gofmt
|
||||||
|
|
|
@ -25,9 +25,9 @@ autopath.Func. Note the searchpath must be ending with the empty string.
|
||||||
|
|
||||||
I.e:
|
I.e:
|
||||||
|
|
||||||
func (m Plugins ) AutoPath(state request.Request) []string {
|
func (m Plugins ) AutoPath(state request.Request) []string {
|
||||||
return []string{"first", "second", "last", ""}
|
return []string{"first", "second", "last", ""}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
package autopath
|
package autopath
|
||||||
|
|
||||||
|
|
|
@ -77,18 +77,18 @@ func TestAzure(t *testing.T) {
|
||||||
expectedErr error
|
expectedErr error
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
qname: "example.org.",
|
qname: "example.org.",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeSOA,
|
qtype: dns.TypeSOA,
|
||||||
wantAnswer: []string{"org. 300 IN SOA ns1-06.azure-dns.com. azuredns-hostmaster.microsoft.com. 1 3600 300 2419200 300"},
|
wantAnswer: []string{"org. 300 IN SOA ns1-06.azure-dns.com. azuredns-hostmaster.microsoft.com. 1 3600 300 2419200 300"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -98,38 +98,38 @@ func TestAzure(t *testing.T) {
|
||||||
wantMsgRCode: dns.RcodeServerFailure,
|
wantMsgRCode: dns.RcodeServerFailure,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "example.gov",
|
qname: "example.gov",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeSRV,
|
qtype: dns.TypeSRV,
|
||||||
wantAnswer: []string{"example.org. 300 IN SRV 1 10 5269 srv-1.example.com.", "example.org. 300 IN SRV 1 10 5269 srv-2.example.com."},
|
wantAnswer: []string{"example.org. 300 IN SRV 1 10 5269 srv-1.example.com.", "example.org. 300 IN SRV 1 10 5269 srv-2.example.com."},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "cname.example.org.",
|
qname: "cname.example.org.",
|
||||||
qtype: dns.TypeCNAME,
|
qtype: dns.TypeCNAME,
|
||||||
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org."},
|
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org."},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "cname.example.org.",
|
qname: "cname.example.org.",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org.", "example.org. 300 IN A 1.2.3.4"},
|
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org.", "example.org. 300 IN A 1.2.3.4"},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "mail.example.org.",
|
qname: "mail.example.org.",
|
||||||
qtype: dns.TypeMX,
|
qtype: dns.TypeMX,
|
||||||
wantAnswer: []string{"mail.example.org. 300 IN MX 10 mailserver.example.com."},
|
wantAnswer: []string{"mail.example.org. 300 IN MX 10 mailserver.example.com."},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "ptr.example.org.",
|
qname: "ptr.example.org.",
|
||||||
qtype: dns.TypePTR,
|
qtype: dns.TypePTR,
|
||||||
wantAnswer: []string{"ptr.example.org. 300 IN PTR www.ptr-example.com."},
|
wantAnswer: []string{"ptr.example.org. 300 IN PTR www.ptr-example.com."},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
qname: "txt.example.org.",
|
qname: "txt.example.org.",
|
||||||
qtype: dns.TypeTXT,
|
qtype: dns.TypeTXT,
|
||||||
wantAnswer: []string{"txt.example.org. 300 IN TXT \"TXT for example.org\""},
|
wantAnswer: []string{"txt.example.org. 300 IN TXT \"TXT for example.org\""},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,20 +183,20 @@ func TestCloudDNS(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
// 0. example.org A found - success.
|
// 0. example.org A found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
||||||
},
|
},
|
||||||
// 1. example.org AAAA found - success.
|
// 1. example.org AAAA found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
||||||
},
|
},
|
||||||
// 2. exampled.org PTR found - success.
|
// 2. exampled.org PTR found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypePTR,
|
qtype: dns.TypePTR,
|
||||||
wantAnswer: []string{"example.org. 300 IN PTR ptr.example.org."},
|
wantAnswer: []string{"example.org. 300 IN PTR ptr.example.org."},
|
||||||
},
|
},
|
||||||
// 3. sample.example.org points to example.org CNAME.
|
// 3. sample.example.org points to example.org CNAME.
|
||||||
|
@ -212,14 +212,14 @@ func TestCloudDNS(t *testing.T) {
|
||||||
// 4. Explicit CNAME query for sample.example.org.
|
// 4. Explicit CNAME query for sample.example.org.
|
||||||
// Query must return just CNAME.
|
// Query must return just CNAME.
|
||||||
{
|
{
|
||||||
qname: "sample.example.org",
|
qname: "sample.example.org",
|
||||||
qtype: dns.TypeCNAME,
|
qtype: dns.TypeCNAME,
|
||||||
wantAnswer: []string{"sample.example.org. 300 IN CNAME example.org."},
|
wantAnswer: []string{"sample.example.org. 300 IN CNAME example.org."},
|
||||||
},
|
},
|
||||||
// 5. Explicit SOA query for example.org.
|
// 5. Explicit SOA query for example.org.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeNS,
|
qtype: dns.TypeNS,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
||||||
},
|
},
|
||||||
// 6. AAAA query for split-example.org must return NODATA.
|
// 6. AAAA query for split-example.org must return NODATA.
|
||||||
|
@ -227,7 +227,7 @@ func TestCloudDNS(t *testing.T) {
|
||||||
qname: "split-example.gov",
|
qname: "split-example.gov",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantRetCode: dns.RcodeSuccess,
|
wantRetCode: dns.RcodeSuccess,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
||||||
},
|
},
|
||||||
// 7. Zone not configured.
|
// 7. Zone not configured.
|
||||||
{
|
{
|
||||||
|
@ -242,24 +242,24 @@ func TestCloudDNS(t *testing.T) {
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantRetCode: dns.RcodeSuccess,
|
wantRetCode: dns.RcodeSuccess,
|
||||||
wantMsgRCode: dns.RcodeNameError,
|
wantMsgRCode: dns.RcodeNameError,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
wantNS: []string{"org. 300 IN SOA ns-cloud-c1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
||||||
},
|
},
|
||||||
// 9. No record found. Fallthrough.
|
// 9. No record found. Fallthrough.
|
||||||
{
|
{
|
||||||
qname: "example.gov",
|
qname: "example.gov",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
||||||
},
|
},
|
||||||
// 10. other-zone.example.org is stored in a different hosted zone. success
|
// 10. other-zone.example.org is stored in a different hosted zone. success
|
||||||
{
|
{
|
||||||
qname: "other-example.org",
|
qname: "other-example.org",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"other-example.org. 300 IN A 3.5.7.9"},
|
wantAnswer: []string{"other-example.org. 300 IN A 3.5.7.9"},
|
||||||
},
|
},
|
||||||
// 11. split-example.org only has A record. Expect NODATA.
|
// 11. split-example.org only has A record. Expect NODATA.
|
||||||
{
|
{
|
||||||
qname: "split-example.org",
|
qname: "split-example.org",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-cloud-e1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
wantNS: []string{"org. 300 IN SOA ns-cloud-e1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 300 259200 300"},
|
||||||
},
|
},
|
||||||
// 12. *.www.example.org is a wildcard CNAME to www.example.org.
|
// 12. *.www.example.org is a wildcard CNAME to www.example.org.
|
||||||
|
|
|
@ -59,6 +59,6 @@ func TestBlackLiesBitmapNameError(t *testing.T) {
|
||||||
func testTLSAMsg() *dns.Msg {
|
func testTLSAMsg() *dns.Msg {
|
||||||
return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess},
|
return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess},
|
||||||
Question: []dns.Question{{Name: "25._tcp.example.org.", Qclass: dns.ClassINET, Qtype: dns.TypeTLSA}},
|
Question: []dns.Question{{Name: "25._tcp.example.org.", Qclass: dns.ClassINET, Qtype: dns.TypeTLSA}},
|
||||||
Ns: []dns.RR{test.SOA("example.org. 1800 IN SOA linode.example.org. miek.example.org. 1461471181 14400 3600 604800 14400")},
|
Ns: []dns.RR{test.SOA("example.org. 1800 IN SOA linode.example.org. miek.example.org. 1461471181 14400 3600 604800 14400")},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,12 +185,12 @@ var apexWildcardTestCases = []test.Case{
|
||||||
{
|
{
|
||||||
Qname: "foo.example.org.", Qtype: dns.TypeA,
|
Qname: "foo.example.org.", Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)},
|
Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)},
|
||||||
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "bar.example.org.", Qtype: dns.TypeA,
|
Qname: "bar.example.org.", Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)},
|
Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)},
|
||||||
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -225,17 +225,17 @@ var multiWildcardTestCases = []test.Case{
|
||||||
{
|
{
|
||||||
Qname: "foo.example.org.", Qtype: dns.TypeA,
|
Qname: "foo.example.org.", Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)},
|
Answer: []dns.RR{test.A(`foo.example.org. 3600 IN A 127.0.0.54`)},
|
||||||
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "bar.example.org.", Qtype: dns.TypeA,
|
Qname: "bar.example.org.", Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)},
|
Answer: []dns.RR{test.A(`bar.example.org. 3600 IN A 127.0.0.53`)},
|
||||||
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Qname: "bar.intern.example.org.", Qtype: dns.TypeA,
|
Qname: "bar.intern.example.org.", Qtype: dns.TypeA,
|
||||||
Answer: []dns.RR{test.A(`bar.intern.example.org. 3600 IN A 127.0.1.52`)},
|
Answer: []dns.RR{test.A(`bar.intern.example.org. 3600 IN A 127.0.1.52`)},
|
||||||
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
Ns: []dns.RR{test.NS(`example.org. 3600 IN NS b.iana-servers.net.`)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ NXDOMAIN depending on the state of the cluster.
|
||||||
|
|
||||||
A plugin willing to provide these services must implement the Externaler interface, although it
|
A plugin willing to provide these services must implement the Externaler interface, although it
|
||||||
likely only makes sense for the *kubernetes* plugin.
|
likely only makes sense for the *kubernetes* plugin.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
package external
|
package external
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ var tests = []test.Case{
|
||||||
{
|
{
|
||||||
Qname: "svc1.testns.example.com.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess,
|
Qname: "svc1.testns.example.com.", Qtype: dns.TypeSRV, Rcode: dns.RcodeSuccess,
|
||||||
Answer: []dns.RR{test.SRV("svc1.testns.example.com. 5 IN SRV 0 100 80 svc1.testns.example.com.")},
|
Answer: []dns.RR{test.SRV("svc1.testns.example.com. 5 IN SRV 0 100 80 svc1.testns.example.com.")},
|
||||||
Extra: []dns.RR{test.A("svc1.testns.example.com. 5 IN A 1.2.3.4")},
|
Extra: []dns.RR{test.A("svc1.testns.example.com. 5 IN A 1.2.3.4")},
|
||||||
},
|
},
|
||||||
// SRV Service Not udp/tcp
|
// SRV Service Not udp/tcp
|
||||||
{
|
{
|
||||||
|
|
|
@ -210,7 +210,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
|
||||||
return services, headlessServices
|
return services, headlessServices
|
||||||
}
|
}
|
||||||
|
|
||||||
//ExternalSerial returns the serial of the external zone
|
// ExternalSerial returns the serial of the external zone
|
||||||
func (k *Kubernetes) ExternalSerial(string) uint32 {
|
func (k *Kubernetes) ExternalSerial(string) uint32 {
|
||||||
return uint32(k.APIConn.Modified(true))
|
return uint32(k.APIConn.Modified(true))
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ w1,example.org
|
||||||
`
|
`
|
||||||
|
|
||||||
var testOneDomainWRR = map[string]weights{
|
var testOneDomainWRR = map[string]weights{
|
||||||
"w1,example.org.": weights{
|
"w1,example.org.": {
|
||||||
&weightItem{net.ParseIP("192.168.1.15"), uint8(10)},
|
&weightItem{net.ParseIP("192.168.1.15"), uint8(10)},
|
||||||
&weightItem{net.ParseIP("192.168.1.14"), uint8(20)},
|
&weightItem{net.ParseIP("192.168.1.14"), uint8(20)},
|
||||||
},
|
},
|
||||||
|
@ -43,12 +43,12 @@ w2.example.org
|
||||||
`
|
`
|
||||||
|
|
||||||
var testTwoDomainsWRR = map[string]weights{
|
var testTwoDomainsWRR = map[string]weights{
|
||||||
"w1.example.org.": weights{
|
"w1.example.org.": {
|
||||||
&weightItem{net.ParseIP("192.168.1.15"), uint8(10)},
|
&weightItem{net.ParseIP("192.168.1.15"), uint8(10)},
|
||||||
&weightItem{net.ParseIP("192.168.1.14"), uint8(20)},
|
&weightItem{net.ParseIP("192.168.1.14"), uint8(20)},
|
||||||
},
|
},
|
||||||
"w2.example.org.": weights{},
|
"w2.example.org.": {},
|
||||||
"w3.example.org.": weights{
|
"w3.example.org.": {
|
||||||
&weightItem{net.ParseIP("192.168.2.16"), uint8(11)},
|
&weightItem{net.ParseIP("192.168.2.16"), uint8(11)},
|
||||||
&weightItem{net.ParseIP("192.168.2.15"), uint8(12)},
|
&weightItem{net.ParseIP("192.168.2.15"), uint8(12)},
|
||||||
&weightItem{net.ParseIP("192.168.2.14"), uint8(13)},
|
&weightItem{net.ParseIP("192.168.2.14"), uint8(13)},
|
||||||
|
@ -234,17 +234,17 @@ func TestLoadBalanceWRR(t *testing.T) {
|
||||||
|
|
||||||
// domain maps to test
|
// domain maps to test
|
||||||
oneDomain := map[string]weights{
|
oneDomain := map[string]weights{
|
||||||
"endpoint.region2.skydns.test.": weights{
|
"endpoint.region2.skydns.test.": {
|
||||||
&weightItem{net.ParseIP("10.240.0.2"), uint8(3)},
|
&weightItem{net.ParseIP("10.240.0.2"), uint8(3)},
|
||||||
&weightItem{net.ParseIP("10.240.0.1"), uint8(2)},
|
&weightItem{net.ParseIP("10.240.0.1"), uint8(2)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
twoDomains := map[string]weights{
|
twoDomains := map[string]weights{
|
||||||
"endpoint.region2.skydns.test.": weights{
|
"endpoint.region2.skydns.test.": {
|
||||||
&weightItem{net.ParseIP("10.240.0.2"), uint8(5)},
|
&weightItem{net.ParseIP("10.240.0.2"), uint8(5)},
|
||||||
&weightItem{net.ParseIP("10.240.0.1"), uint8(2)},
|
&weightItem{net.ParseIP("10.240.0.1"), uint8(2)},
|
||||||
},
|
},
|
||||||
"endpoint.region1.skydns.test.": weights{
|
"endpoint.region1.skydns.test.": {
|
||||||
&weightItem{net.ParseIP("::2"), uint8(4)},
|
&weightItem{net.ParseIP("::2"), uint8(4)},
|
||||||
&weightItem{net.ParseIP("::1"), uint8(3)},
|
&weightItem{net.ParseIP("::1"), uint8(3)},
|
||||||
},
|
},
|
||||||
|
|
|
@ -8,33 +8,32 @@
|
||||||
//
|
//
|
||||||
// Implement the Provider interface for a plugin p:
|
// Implement the Provider interface for a plugin p:
|
||||||
//
|
//
|
||||||
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
||||||
// metadata.SetValueFunc(ctx, "test/something", func() string { return "myvalue" })
|
// metadata.SetValueFunc(ctx, "test/something", func() string { return "myvalue" })
|
||||||
// return ctx
|
// return ctx
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Basic example with caching:
|
// Basic example with caching:
|
||||||
//
|
//
|
||||||
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
|
||||||
// cached := ""
|
// cached := ""
|
||||||
// f := func() string {
|
// f := func() string {
|
||||||
// if cached != "" {
|
// if cached != "" {
|
||||||
// return cached
|
// return cached
|
||||||
// }
|
// }
|
||||||
// cached = expensiveFunc()
|
// cached = expensiveFunc()
|
||||||
// return cached
|
// return cached
|
||||||
// }
|
// }
|
||||||
// metadata.SetValueFunc(ctx, "test/something", f)
|
// metadata.SetValueFunc(ctx, "test/something", f)
|
||||||
// return ctx
|
// return ctx
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// If you need access to this metadata from another plugin:
|
// If you need access to this metadata from another plugin:
|
||||||
//
|
//
|
||||||
// // ...
|
// // ...
|
||||||
// valueFunc := metadata.ValueFunc(ctx, "test/something")
|
// valueFunc := metadata.ValueFunc(ctx, "test/something")
|
||||||
// value := valueFunc()
|
// value := valueFunc()
|
||||||
// // use 'value'
|
// // use 'value'
|
||||||
//
|
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
// See https://github.com/coredns/coredns/issues/2723 for some discussion on this, which includes this quote:
|
// See https://github.com/coredns/coredns/issues/2723 for some discussion on this, which includes this quote:
|
||||||
//
|
//
|
||||||
// TL;DR: `fallthrough` is indeed risky and hackish, but still a good feature of CoreDNS as it allows to quickly answer boring edge cases.
|
// TL;DR: `fallthrough` is indeed risky and hackish, but still a good feature of CoreDNS as it allows to quickly answer boring edge cases.
|
||||||
//
|
|
||||||
package fall
|
package fall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
@ -31,28 +31,31 @@ func setTLSDefaults(ctls *tls.Config) {
|
||||||
// in list of arguments. Typically these come straight from the
|
// in list of arguments. Typically these come straight from the
|
||||||
// Corefile.
|
// Corefile.
|
||||||
// no args
|
// no args
|
||||||
// - creates a Config with no cert and using system CAs
|
// - creates a Config with no cert and using system CAs
|
||||||
// - use for a client that talks to a server with a public signed cert (CA installed in system)
|
// - use for a client that talks to a server with a public signed cert (CA installed in system)
|
||||||
// - the client will not be authenticated by the server since there is no cert
|
// - the client will not be authenticated by the server since there is no cert
|
||||||
|
//
|
||||||
// one arg: the path to CA PEM file
|
// one arg: the path to CA PEM file
|
||||||
// - creates a Config with no cert using a specific CA
|
// - creates a Config with no cert using a specific CA
|
||||||
// - use for a client that talks to a server with a private signed cert (CA not installed in system)
|
// - use for a client that talks to a server with a private signed cert (CA not installed in system)
|
||||||
// - the client will not be authenticated by the server since there is no cert
|
// - the client will not be authenticated by the server since there is no cert
|
||||||
|
//
|
||||||
// two args: path to cert PEM file, the path to private key PEM file
|
// two args: path to cert PEM file, the path to private key PEM file
|
||||||
// - creates a Config with a cert, using system CAs to validate the other end
|
// - creates a Config with a cert, using system CAs to validate the other end
|
||||||
// - use for:
|
// - use for:
|
||||||
// - a server; or,
|
// - a server; or,
|
||||||
// - a client that talks to a server with a public cert and needs certificate-based authentication
|
// - a client that talks to a server with a public cert and needs certificate-based authentication
|
||||||
// - the other end will authenticate this end via the provided cert
|
// - the other end will authenticate this end via the provided cert
|
||||||
// - the cert of the other end will be verified via system CAs
|
// - the cert of the other end will be verified via system CAs
|
||||||
|
//
|
||||||
// three args: path to cert PEM file, path to client private key PEM file, path to CA PEM file
|
// three args: path to cert PEM file, path to client private key PEM file, path to CA PEM file
|
||||||
// - creates a Config with the cert, using specified CA to validate the other end
|
// - creates a Config with the cert, using specified CA to validate the other end
|
||||||
// - use for:
|
// - use for:
|
||||||
// - a server; or,
|
// - a server; or,
|
||||||
// - a client that talks to a server with a privately signed cert and needs certificate-based
|
// - a client that talks to a server with a privately signed cert and needs certificate-based
|
||||||
// authentication
|
// authentication
|
||||||
// - the other end will authenticate this end via the provided cert
|
// - the other end will authenticate this end via the provided cert
|
||||||
// - this end will verify the other end's cert using the specified CA
|
// - this end will verify the other end's cert using the specified CA
|
||||||
func NewTLSConfigFromArgs(args ...string) (*tls.Config, error) {
|
func NewTLSConfigFromArgs(args ...string) (*tls.Config, error) {
|
||||||
var err error
|
var err error
|
||||||
var c *tls.Config
|
var c *tls.Config
|
||||||
|
|
|
@ -167,8 +167,9 @@ const escapeSeq = "\\"
|
||||||
// for everything else.
|
// for everything else.
|
||||||
//
|
//
|
||||||
// Example:
|
// Example:
|
||||||
// `\\052.example.com.` -> `*.example.com`
|
//
|
||||||
// `\\137.example.com.` -> error ('_' is not valid)
|
// `\\052.example.com.` -> `*.example.com`
|
||||||
|
// `\\137.example.com.` -> error ('_' is not valid)
|
||||||
func maybeUnescape(s string) (string, error) {
|
func maybeUnescape(s string) (string, error) {
|
||||||
var out string
|
var out string
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -131,20 +131,20 @@ func TestRoute53(t *testing.T) {
|
||||||
}{
|
}{
|
||||||
// 0. example.org A found - success.
|
// 0. example.org A found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
|
||||||
},
|
},
|
||||||
// 1. example.org AAAA found - success.
|
// 1. example.org AAAA found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
|
||||||
},
|
},
|
||||||
// 2. exampled.org PTR found - success.
|
// 2. exampled.org PTR found - success.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypePTR,
|
qtype: dns.TypePTR,
|
||||||
wantAnswer: []string{"example.org. 300 IN PTR ptr.example.org."},
|
wantAnswer: []string{"example.org. 300 IN PTR ptr.example.org."},
|
||||||
},
|
},
|
||||||
// 3. sample.example.org points to example.org CNAME.
|
// 3. sample.example.org points to example.org CNAME.
|
||||||
|
@ -160,14 +160,14 @@ func TestRoute53(t *testing.T) {
|
||||||
// 4. Explicit CNAME query for sample.example.org.
|
// 4. Explicit CNAME query for sample.example.org.
|
||||||
// Query must return just CNAME.
|
// Query must return just CNAME.
|
||||||
{
|
{
|
||||||
qname: "sample.example.org",
|
qname: "sample.example.org",
|
||||||
qtype: dns.TypeCNAME,
|
qtype: dns.TypeCNAME,
|
||||||
wantAnswer: []string{"sample.example.org. 300 IN CNAME example.org."},
|
wantAnswer: []string{"sample.example.org. 300 IN CNAME example.org."},
|
||||||
},
|
},
|
||||||
// 5. Explicit SOA query for example.org.
|
// 5. Explicit SOA query for example.org.
|
||||||
{
|
{
|
||||||
qname: "example.org",
|
qname: "example.org",
|
||||||
qtype: dns.TypeNS,
|
qtype: dns.TypeNS,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
||||||
},
|
},
|
||||||
// 6. AAAA query for split-example.org must return NODATA.
|
// 6. AAAA query for split-example.org must return NODATA.
|
||||||
|
@ -175,7 +175,7 @@ func TestRoute53(t *testing.T) {
|
||||||
qname: "split-example.gov",
|
qname: "split-example.gov",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantRetCode: dns.RcodeSuccess,
|
wantRetCode: dns.RcodeSuccess,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
||||||
},
|
},
|
||||||
// 7. Zone not configured.
|
// 7. Zone not configured.
|
||||||
{
|
{
|
||||||
|
@ -190,24 +190,24 @@ func TestRoute53(t *testing.T) {
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantRetCode: dns.RcodeSuccess,
|
wantRetCode: dns.RcodeSuccess,
|
||||||
wantMsgRCode: dns.RcodeNameError,
|
wantMsgRCode: dns.RcodeNameError,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
wantNS: []string{"org. 300 IN SOA ns-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
||||||
},
|
},
|
||||||
// 9. No record found. Fallthrough.
|
// 9. No record found. Fallthrough.
|
||||||
{
|
{
|
||||||
qname: "example.gov",
|
qname: "example.gov",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
|
||||||
},
|
},
|
||||||
// 10. other-zone.example.org is stored in a different hosted zone. success
|
// 10. other-zone.example.org is stored in a different hosted zone. success
|
||||||
{
|
{
|
||||||
qname: "other-example.org",
|
qname: "other-example.org",
|
||||||
qtype: dns.TypeA,
|
qtype: dns.TypeA,
|
||||||
wantAnswer: []string{"other-example.org. 300 IN A 3.5.7.9"},
|
wantAnswer: []string{"other-example.org. 300 IN A 3.5.7.9"},
|
||||||
},
|
},
|
||||||
// 11. split-example.org only has A record. Expect NODATA.
|
// 11. split-example.org only has A record. Expect NODATA.
|
||||||
{
|
{
|
||||||
qname: "split-example.org",
|
qname: "split-example.org",
|
||||||
qtype: dns.TypeAAAA,
|
qtype: dns.TypeAAAA,
|
||||||
wantNS: []string{"org. 300 IN SOA ns-15.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
wantNS: []string{"org. 300 IN SOA ns-15.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
|
||||||
},
|
},
|
||||||
// 12. *.www.example.org is a wildcard CNAME to www.example.org.
|
// 12. *.www.example.org is a wildcard CNAME to www.example.org.
|
||||||
|
|
|
@ -35,9 +35,11 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM=
|
||||||
// actually works. Each corefile snippet is only used if the language is set to 'corefile':
|
// actually works. Each corefile snippet is only used if the language is set to 'corefile':
|
||||||
//
|
//
|
||||||
// ~~~ corefile
|
// ~~~ corefile
|
||||||
// . {
|
//
|
||||||
// # 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:
|
// While we're at it - we also check the README.md itself. It should at least have the sections:
|
||||||
|
|
Loading…
Add table
Reference in a new issue