replace reviewdog fully by golangci-lint (#6139)

Signed-off-by: Ondřej Benkovský <ondrej.benkovsky@jamf.com>
This commit is contained in:
Ondřej Benkovský 2023-06-09 18:08:23 +02:00 committed by GitHub
parent 6d3db023fe
commit 8c489bd400
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 125 additions and 146 deletions

View file

@ -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

View file

@ -9,3 +9,4 @@ linters:
- typecheck
- whitespace
- unused
- gofmt

View file

@ -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

View file

@ -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"},
},
{
@ -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\""},
},
}

View file

@ -183,20 +183,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.
@ -212,14 +212,14 @@ 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.
@ -227,7 +227,7 @@ func TestCloudDNS(t *testing.T) {
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.
{
@ -242,24 +242,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.

View file

@ -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")},
}
}

View file

@ -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.`)},
},
}
@ -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.`)},
},
}

View file

@ -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

View file

@ -87,7 +87,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
{

View file

@ -210,7 +210,7 @@ func (k *Kubernetes) ExternalServices(zone string, headless bool) (services []ms
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 {
return uint32(k.APIConn.Modified(true))
}

View file

@ -21,7 +21,7 @@ w1,example.org
`
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.14"), uint8(20)},
},
@ -43,12 +43,12 @@ w2.example.org
`
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.14"), uint8(20)},
},
"w2.example.org.": weights{},
"w3.example.org.": weights{
"w2.example.org.": {},
"w3.example.org.": {
&weightItem{net.ParseIP("192.168.2.16"), uint8(11)},
&weightItem{net.ParseIP("192.168.2.15"), uint8(12)},
&weightItem{net.ParseIP("192.168.2.14"), uint8(13)},
@ -234,17 +234,17 @@ func TestLoadBalanceWRR(t *testing.T) {
// domain maps to test
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.1"), uint8(2)},
},
}
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.1"), uint8(2)},
},
"endpoint.region1.skydns.test.": weights{
"endpoint.region1.skydns.test.": {
&weightItem{net.ParseIP("::2"), uint8(4)},
&weightItem{net.ParseIP("::1"), uint8(3)},
},

View file

@ -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 (

View file

@ -10,7 +10,6 @@
// 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.
//
package fall
import (

View file

@ -31,28 +31,31 @@ func setTLSDefaults(ctls *tls.Config) {
// in list of arguments. Typically these come straight from the
// Corefile.
// no args
// - 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)
// - the client will not be authenticated by the server since there is no cert
// - 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)
// - the client will not be authenticated by the server since there is no cert
//
// one arg: the path to CA PEM file
// - 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)
// - the client will not be authenticated by the server since there is no cert
// - 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)
// - 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
// - creates a Config with a cert, using system CAs to validate the other end
// - use for:
// - a server; or,
// - 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 cert of the other end will be verified via system CAs
// - creates a Config with a cert, using system CAs to validate the other end
// - use for:
// - a server; or,
// - 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 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
// - creates a Config with the cert, using specified CA to validate the other end
// - use for:
// - a server; or,
// - a client that talks to a server with a privately signed cert and needs certificate-based
// authentication
// - the other end will authenticate this end via the provided cert
// - this end will verify the other end's cert using the specified CA
// - creates a Config with the cert, using specified CA to validate the other end
// - use for:
// - a server; or,
// - a client that talks to a server with a privately signed cert and needs certificate-based
// authentication
// - the other end will authenticate this end via the provided cert
// - this end will verify the other end's cert using the specified CA
func NewTLSConfigFromArgs(args ...string) (*tls.Config, error) {
var err error
var c *tls.Config

View file

@ -167,8 +167,9 @@ const escapeSeq = "\\"
// for everything else.
//
// 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) {
var out string
for {

View file

@ -131,20 +131,20 @@ func TestRoute53(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.
@ -160,14 +160,14 @@ func TestRoute53(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-1536.awsdns-00.co.uk. awsdns-hostmaster.amazon.com. 1 7200 900 1209600 86400"},
},
// 6. AAAA query for split-example.org must return NODATA.
@ -175,7 +175,7 @@ func TestRoute53(t *testing.T) {
qname: "split-example.gov",
qtype: dns.TypeAAAA,
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.
{
@ -190,24 +190,24 @@ func TestRoute53(t *testing.T) {
qtype: dns.TypeA,
wantRetCode: dns.RcodeSuccess,
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.
{
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-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.

View file

@ -35,9 +35,11 @@ PrivateKey: f03VplaIEA+KHI9uizlemUSbUJH86hPBPjmcUninPoM=
// actually works. Each corefile snippet is only used if the language is set to '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: