Skip to content

Commit

Permalink
auto go fmt
Browse files Browse the repository at this point in the history
Signed-off-by: coredns[bot] <[email protected]>
  • Loading branch information
coredns[bot] committed Apr 10, 2023
1 parent 2fe5273 commit dff16f1
Show file tree
Hide file tree
Showing 20 changed files with 133 additions and 128 deletions.
3 changes: 2 additions & 1 deletion core/dnsserver/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,8 @@ func (c *Config) AddPlugin(m plugin.Plugin) {
}

// registerHandler adds a handler to a site's handler registration. Handlers
// use this to announce that they exist to other plugin.
//
// use this to announce that they exist to other plugin.
func (c *Config) registerHandler(h plugin.Handler) {
if c.registry == nil {
c.registry = make(map[string]plugin.Handler)
Expand Down
6 changes: 3 additions & 3 deletions plugin/autopath/autopath.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ autopath.Func. Note the searchpath must be ending with the empty string.
I.e:
func (m Plugins ) AutoPath(state request.Request) []string {
return []string{"first", "second", "last", ""}
}
func (m Plugins ) AutoPath(state request.Request) []string {
return []string{"first", "second", "last", ""}
}
*/
package autopath

Expand Down
40 changes: 20 additions & 20 deletions plugin/azure/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ func TestAzure(t *testing.T) {
expectedErr error
}{
{
qname: "example.org.",
qtype: dns.TypeA,
qname: "example.org.",
qtype: dns.TypeA,
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
},
{
qname: "example.org",
qtype: dns.TypeAAAA,
qname: "example.org",
qtype: dns.TypeAAAA,
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
},
{
qname: "example.org",
qtype: dns.TypeSOA,
qname: "example.org",
qtype: dns.TypeSOA,
wantAnswer: []string{"org. 300 IN SOA ns1-06.azure-dns.com. azuredns-hostmaster.microsoft.com. 1 3600 300 2419200 300"},
},
{
Expand All @@ -98,38 +98,38 @@ func TestAzure(t *testing.T) {
wantMsgRCode: dns.RcodeServerFailure,
},
{
qname: "example.gov",
qtype: dns.TypeA,
qname: "example.gov",
qtype: dns.TypeA,
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
},
{
qname: "example.org",
qtype: dns.TypeSRV,
qname: "example.org",
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."},
},
{
qname: "cname.example.org.",
qtype: dns.TypeCNAME,
qname: "cname.example.org.",
qtype: dns.TypeCNAME,
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org."},
},
{
qname: "cname.example.org.",
qtype: dns.TypeA,
qname: "cname.example.org.",
qtype: dns.TypeA,
wantAnswer: []string{"cname.example.org. 300 IN CNAME example.org.", "example.org. 300 IN A 1.2.3.4"},
},
{
qname: "mail.example.org.",
qtype: dns.TypeMX,
qname: "mail.example.org.",
qtype: dns.TypeMX,
wantAnswer: []string{"mail.example.org. 300 IN MX 10 mailserver.example.com."},
},
{
qname: "ptr.example.org.",
qtype: dns.TypePTR,
qname: "ptr.example.org.",
qtype: dns.TypePTR,
wantAnswer: []string{"ptr.example.org. 300 IN PTR www.ptr-example.com."},
},
{
qname: "txt.example.org.",
qtype: dns.TypeTXT,
qname: "txt.example.org.",
qtype: dns.TypeTXT,
wantAnswer: []string{"txt.example.org. 300 IN TXT \"TXT for example.org\""},
},
}
Expand Down
36 changes: 18 additions & 18 deletions plugin/clouddns/clouddns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,20 +174,20 @@ func TestCloudDNS(t *testing.T) {
}{
// 0. example.org A found - success.
{
qname: "example.org",
qtype: dns.TypeA,
qname: "example.org",
qtype: dns.TypeA,
wantAnswer: []string{"example.org. 300 IN A 1.2.3.4"},
},
// 1. example.org AAAA found - success.
{
qname: "example.org",
qtype: dns.TypeAAAA,
qname: "example.org",
qtype: dns.TypeAAAA,
wantAnswer: []string{"example.org. 300 IN AAAA 2001:db8:85a3::8a2e:370:7334"},
},
// 2. exampled.org PTR found - success.
{
qname: "example.org",
qtype: dns.TypePTR,
qname: "example.org",
qtype: dns.TypePTR,
wantAnswer: []string{"example.org. 300 IN PTR ptr.example.org."},
},
// 3. sample.example.org points to example.org CNAME.
Expand All @@ -203,22 +203,22 @@ func TestCloudDNS(t *testing.T) {
// 4. Explicit CNAME query for sample.example.org.
// Query must return just CNAME.
{
qname: "sample.example.org",
qtype: dns.TypeCNAME,
qname: "sample.example.org",
qtype: dns.TypeCNAME,
wantAnswer: []string{"sample.example.org. 300 IN CNAME example.org."},
},
// 5. Explicit SOA query for example.org.
{
qname: "example.org",
qtype: dns.TypeNS,
qname: "example.org",
qtype: dns.TypeNS,
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.
{
qname: "split-example.gov",
qtype: dns.TypeAAAA,
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.
{
Expand All @@ -233,24 +233,24 @@ func TestCloudDNS(t *testing.T) {
qtype: dns.TypeA,
wantRetCode: dns.RcodeSuccess,
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.
{
qname: "example.gov",
qtype: dns.TypeA,
qname: "example.gov",
qtype: dns.TypeA,
wantAnswer: []string{"example.gov. 300 IN A 2.4.6.8"},
},
// 10. other-zone.example.org is stored in a different hosted zone. success
{
qname: "other-example.org",
qtype: dns.TypeA,
qname: "other-example.org",
qtype: dns.TypeA,
wantAnswer: []string{"other-example.org. 300 IN A 3.5.7.9"},
},
// 11. split-example.org only has A record. Expect NODATA.
{
qname: "split-example.org",
qtype: dns.TypeAAAA,
qname: "split-example.org",
qtype: dns.TypeAAAA,
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.
Expand Down
2 changes: 2 additions & 0 deletions plugin/dnssec/black_lies.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import (
// See https://tools.ietf.org/html/draft-valsorda-dnsop-black-lies-00
// For example, a request for the non-existing name a.example.com would
// cause the following NSEC record to be generated:
//
// a.example.com. 3600 IN NSEC \000.a.example.com. ( RRSIG NSEC ... )
//
// This inturn makes every NXDOMAIN answer a NODATA one, don't forget to flip
// the header rcode to NOERROR.
func (d Dnssec) nsec(state request.Request, mt response.Type, ttl, incep, expir uint32, server string) ([]dns.RR, error) {
Expand Down
2 changes: 1 addition & 1 deletion plugin/dnssec/black_lies_bitmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@ func TestBlackLiesBitmapNameError(t *testing.T) {
func testTLSAMsg() *dns.Msg {
return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess},
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")},
}
}
4 changes: 2 additions & 2 deletions plugin/dnssec/black_lies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func TestBlackLiesNoError(t *testing.T) {
func testNxdomainMsg() *dns.Msg {
return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeNameError},
Question: []dns.Question{{Name: "ww.miek.nl.", Qclass: dns.ClassINET, Qtype: dns.TypeTXT}},
Ns: []dns.RR{test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1461471181 14400 3600 604800 14400")},
Ns: []dns.RR{test.SOA("miek.nl. 1800 IN SOA linode.atoom.net. miek.miek.nl. 1461471181 14400 3600 604800 14400")},
}
}

func testSuccessMsg() *dns.Msg {
return &dns.Msg{MsgHdr: dns.MsgHdr{Rcode: dns.RcodeSuccess},
Question: []dns.Question{{Name: "www.miek.nl.", Qclass: dns.ClassINET, Qtype: dns.TypeTXT}},
Answer: []dns.RR{test.TXT(`www.miek.nl. 1800 IN TXT "response"`)},
Answer: []dns.RR{test.TXT(`www.miek.nl. 1800 IN TXT "response"`)},
}
}
4 changes: 2 additions & 2 deletions plugin/dnssec/dnssec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,13 @@ func testMsg() *dns.Msg {
// don't care about the message header
return &dns.Msg{
Answer: []dns.RR{test.MX("miek.nl. 1703 IN MX 1 aspmx.l.google.com.")},
Ns: []dns.RR{test.NS("miek.nl. 1703 IN NS omval.tednet.nl.")},
Ns: []dns.RR{test.NS("miek.nl. 1703 IN NS omval.tednet.nl.")},
}
}
func testMsgEx() *dns.Msg {
return &dns.Msg{
Answer: []dns.RR{test.MX("example.org. 1703 IN MX 1 aspmx.l.google.com.")},
Ns: []dns.RR{test.NS("example.org. 1703 IN NS omval.tednet.nl.")},
Ns: []dns.RR{test.NS("example.org. 1703 IN NS omval.tednet.nl.")},
}
}

Expand Down
10 changes: 5 additions & 5 deletions plugin/file/wildcard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,12 @@ var apexWildcardTestCases = []test.Case{
{
Qname: "foo.example.org.", Qtype: dns.TypeA,
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,
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.`)},
},
}

Expand Down Expand Up @@ -225,17 +225,17 @@ var multiWildcardTestCases = []test.Case{
{
Qname: "foo.example.org.", Qtype: dns.TypeA,
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,
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,
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.`)},
},
}

Expand Down
1 change: 0 additions & 1 deletion plugin/k8s_external/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
likely only makes sense for the *kubernetes* plugin.
*/
package external

Expand Down
2 changes: 1 addition & 1 deletion plugin/k8s_external/external_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ var tests = []test.Case{
{
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.")},
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
{
Expand Down
2 changes: 1 addition & 1 deletion plugin/kubernetes/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (k *Kubernetes) ExternalServices(zone string) (services []msg.Service) {
return services
}

//ExternalSerial returns the serial of the external zone
// ExternalSerial returns the serial of the external zone
func (k *Kubernetes) ExternalSerial(string) uint32 {
return uint32(k.APIConn.Modified(true))
}
Expand Down
16 changes: 8 additions & 8 deletions plugin/kubernetes/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ var dnsTestCases = []kubeTestCase{
}},
{Case: test.Case{
Qname: "svc1.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("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")},
Extra: []dns.RR{test.A("svc1.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
}},
{Case: test.Case{
Qname: "svcempty.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svcempty.testns.svc.cluster.local. 5 IN SRV 0 100 80 svcempty.testns.svc.cluster.local.")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
Extra: []dns.RR{test.A("svcempty.testns.svc.cluster.local. 5 IN A 10.0.0.1")},
}},
{Case: test.Case{
Qname: "svc6.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svc6.testns.svc.cluster.local. 5 IN SRV 0 100 80 svc6.testns.svc.cluster.local.")},
Extra: []dns.RR{test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1")},
Extra: []dns.RR{test.AAAA("svc6.testns.svc.cluster.local. 5 IN AAAA 1234:abcd::1")},
}},
// SRV Service
{Case: test.Case{
Expand Down Expand Up @@ -163,7 +163,7 @@ var dnsTestCases = []kubeTestCase{
// AAAA
{Case: test.Case{
Qname: "5678-abcd--2.hdls1.testns.svc.cluster.local", Qtype: dns.TypeAAAA,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.AAAA("5678-abcd--2.hdls1.testns.svc.cluster.local. 5 IN AAAA 5678:abcd::2")},
}},
// CNAME External
Expand Down Expand Up @@ -370,7 +370,7 @@ var dnsTestCases = []kubeTestCase{
}},
{Case: test.Case{
Qname: "svc-dual-stack.testns.svc.cluster.local.", Qtype: dns.TypeSRV,
Rcode: dns.RcodeSuccess,
Rcode: dns.RcodeSuccess,
Answer: []dns.RR{test.SRV("svc-dual-stack.testns.svc.cluster.local. 5 IN SRV 0 50 80 svc-dual-stack.testns.svc.cluster.local.")},
Extra: []dns.RR{
test.A("svc-dual-stack.testns.svc.cluster.local. 5 IN A 10.0.0.3"),
Expand Down
41 changes: 20 additions & 21 deletions plugin/metadata/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,32 @@
//
// Implement the Provider interface for a plugin p:
//
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
// metadata.SetValueFunc(ctx, "test/something", func() string { return "myvalue" })
// return ctx
// }
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
// metadata.SetValueFunc(ctx, "test/something", func() string { return "myvalue" })
// return ctx
// }
//
// Basic example with caching:
//
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
// cached := ""
// f := func() string {
// if cached != "" {
// return cached
// }
// cached = expensiveFunc()
// return cached
// }
// metadata.SetValueFunc(ctx, "test/something", f)
// return ctx
// }
// func (p P) Metadata(ctx context.Context, state request.Request) context.Context {
// cached := ""
// f := func() string {
// if cached != "" {
// return cached
// }
// cached = expensiveFunc()
// return cached
// }
// metadata.SetValueFunc(ctx, "test/something", f)
// return ctx
// }
//
// If you need access to this metadata from another plugin:
//
// // ...
// valueFunc := metadata.ValueFunc(ctx, "test/something")
// value := valueFunc()
// // use 'value'
//
// // ...
// valueFunc := metadata.ValueFunc(ctx, "test/something")
// value := valueFunc()
// // use 'value'
package metadata

import (
Expand Down
Loading

0 comments on commit dff16f1

Please sign in to comment.