Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run gofmt -w -s on codebase #2773

Merged
merged 1 commit into from
Apr 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions core/dnsserver/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ type Key struct{}

// EnableChaos is a map with plugin names for which we should open CH class queries as we block these by default.
var EnableChaos = map[string]struct{}{
"chaos": struct{}{},
"forward": struct{}{},
"proxy": struct{}{},
"chaos": {},
"forward": {},
"proxy": {},
}

// Quiet mode will not show any informative output on initialization.
Expand Down
14 changes: 7 additions & 7 deletions coremain/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,13 +255,13 @@ var (

// flagsBlacklist removes flags with these names from our flagset.
var flagsBlacklist = map[string]struct{}{
"logtostderr": struct{}{},
"alsologtostderr": struct{}{},
"v": struct{}{},
"stderrthreshold": struct{}{},
"vmodule": struct{}{},
"log_backtrace_at": struct{}{},
"log_dir": struct{}{},
"logtostderr": {},
"alsologtostderr": {},
"v": {},
"stderrthreshold": {},
"vmodule": {},
"log_backtrace_at": {},
"log_dir": {},
}

var flagsToKeep []*flag.Flag
2 changes: 1 addition & 1 deletion plugin/chaos/zowners.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package chaos

// Owners are all GitHub handlers of all maintainers.
var Owners = []string{"bradbeam", "chrisohaver", "dilyevsky", "ekleiner", "fastest963", "fturib", "greenpau", "grobie", "inigohu", "isolus", "johnbelamaric", "miekg", "nchrisdk", "nitisht", "pmoroney", "rajansandeep", "rdrozhdzh", "rtreffer", "stp-ip", "superq", "varyoo", "yongtang"}
var Owners = []string{"bradbeam", "chrisohaver", "dilyevsky", "ekleiner", "fastest963", "fturib", "greenpau", "grobie", "inigohu", "isolus", "johnbelamaric", "miekg", "nchrisdk", "nitisht", "pmoroney", "rajansandeep", "rdrozhdzh", "rtreffer", "stp-ip", "superq", "varyoo", "yongtang"}
18 changes: 9 additions & 9 deletions plugin/kubernetes/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type dnsControl struct {

client kubernetes.Interface

selector labels.Selector
selector labels.Selector
namespaceSelector labels.Selector

svcController cache.Controller
Expand Down Expand Up @@ -84,10 +84,10 @@ type dnsControlOpts struct {
ignoreEmptyService bool

// Label handling.
labelSelector *meta.LabelSelector
selector labels.Selector
labelSelector *meta.LabelSelector
selector labels.Selector
namespaceLabelSelector *meta.LabelSelector
namespaceSelector labels.Selector
namespaceSelector labels.Selector

zones []string
endpointNameMode bool
Expand All @@ -96,12 +96,12 @@ type dnsControlOpts struct {
// newDNSController creates a controller for CoreDNS.
func newdnsController(kubeClient kubernetes.Interface, opts dnsControlOpts) *dnsControl {
dns := dnsControl{
client: kubeClient,
selector: opts.selector,
client: kubeClient,
selector: opts.selector,
namespaceSelector: opts.namespaceSelector,
stopCh: make(chan struct{}),
zones: opts.zones,
endpointNameMode: opts.endpointNameMode,
stopCh: make(chan struct{}),
zones: opts.zones,
endpointNameMode: opts.endpointNameMode,
}

dns.svcLister, dns.svcController = object.NewIndexerInformer(
Expand Down
26 changes: 13 additions & 13 deletions plugin/kubernetes/namespace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
)

func TestFilteredNamespaceExists(t *testing.T) {
tests := []struct{
tests := []struct {
expected bool
kubernetesNamespaces map[string]struct{}
testNamespace string
}{
{true, map[string]struct{}{}, "foobar" },
{false, map[string]struct{}{}, "nsnoexist" },
{true, map[string]struct{}{}, "foobar"},
{false, map[string]struct{}{}, "nsnoexist"},
}

k := Kubernetes{}
Expand All @@ -26,15 +26,15 @@ func TestFilteredNamespaceExists(t *testing.T) {
}

func TestNamespaceExposed(t *testing.T) {
tests := []struct{
tests := []struct {
expected bool
kubernetesNamespaces map[string]struct{}
testNamespace string
}{
{true, map[string]struct{}{ "foobar": {} }, "foobar" },
{false, map[string]struct{}{ "foobar": {} }, "nsnoexist" },
{true, map[string]struct{}{}, "foobar" },
{true, map[string]struct{}{}, "nsnoexist" },
{true, map[string]struct{}{"foobar": {}}, "foobar"},
{false, map[string]struct{}{"foobar": {}}, "nsnoexist"},
{true, map[string]struct{}{}, "foobar"},
{true, map[string]struct{}{}, "nsnoexist"},
}

k := Kubernetes{}
Expand All @@ -49,15 +49,15 @@ func TestNamespaceExposed(t *testing.T) {
}

func TestNamespaceValid(t *testing.T) {
tests := []struct{
tests := []struct {
expected bool
kubernetesNamespaces map[string]struct{}
testNamespace string
}{
{true, map[string]struct{}{ "foobar": {} }, "foobar" },
{false, map[string]struct{}{ "foobar": {} }, "nsnoexist" },
{true, map[string]struct{}{}, "foobar" },
{false, map[string]struct{}{}, "nsnoexist" },
{true, map[string]struct{}{"foobar": {}}, "foobar"},
{false, map[string]struct{}{"foobar": {}}, "nsnoexist"},
{true, map[string]struct{}{}, "foobar"},
{false, map[string]struct{}{}, "nsnoexist"},
}

k := Kubernetes{}
Expand Down
38 changes: 19 additions & 19 deletions plugin/log/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,108 +18,108 @@ func TestLogParse(t *testing.T) {
{`log`, false, []Rule{{
NameScope: ".",
Format: DefaultLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org`, false, []Rule{{
NameScope: "example.org.",
Format: DefaultLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org. {common}`, false, []Rule{{
NameScope: "example.org.",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org {combined}`, false, []Rule{{
NameScope: "example.org.",
Format: CombinedLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org.
log example.net {combined}`, false, []Rule{{
NameScope: "example.org.",
Format: DefaultLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}, {
NameScope: "example.net.",
Format: CombinedLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org {host}
log example.org {when}`, false, []Rule{{
NameScope: "example.org.",
Format: "{host}",
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}, {
NameScope: "example.org.",
Format: "{when}",
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org example.net`, false, []Rule{{
NameScope: "example.org.",
Format: DefaultLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}, {
NameScope: "example.net.",
Format: DefaultLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org example.net {host}`, false, []Rule{{
NameScope: "example.org.",
Format: "{host}",
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}, {
NameScope: "example.net.",
Format: "{host}",
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org example.net {when} {
class denial
}`, false, []Rule{{
NameScope: "example.org.",
Format: "{when}",
Class: map[response.Class]struct{}{response.Denial: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}},
}, {
NameScope: "example.net.",
Format: "{when}",
Class: map[response.Class]struct{}{response.Denial: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}},
}}},

{`log example.org {
class all
}`, false, []Rule{{
NameScope: "example.org.",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.All: struct{}{}},
Class: map[response.Class]struct{}{response.All: {}},
}}},
{`log example.org {
class denial
}`, false, []Rule{{
NameScope: "example.org.",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.Denial: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}},
}}},
{`log {
class denial
}`, false, []Rule{{
NameScope: ".",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.Denial: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}},
}}},
{`log {
class denial error
}`, false, []Rule{{
NameScope: ".",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.Denial: struct{}{}, response.Error: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}, response.Error: {}},
}}},
{`log {
class denial
class error
}`, false, []Rule{{
NameScope: ".",
Format: CommonLogFormat,
Class: map[response.Class]struct{}{response.Denial: struct{}{}, response.Error: struct{}{}},
Class: map[response.Class]struct{}{response.Denial: {}, response.Error: {}},
}}},
{`log {
class abracadabra
Expand Down
34 changes: 17 additions & 17 deletions plugin/metrics/vars/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,24 @@ func Report(server string, req request.Request, zone, rcode string, size int, st
}

var monitorType = map[uint16]struct{}{
dns.TypeAAAA: struct{}{},
dns.TypeA: struct{}{},
dns.TypeCNAME: struct{}{},
dns.TypeDNSKEY: struct{}{},
dns.TypeDS: struct{}{},
dns.TypeMX: struct{}{},
dns.TypeNSEC3: struct{}{},
dns.TypeNSEC: struct{}{},
dns.TypeNS: struct{}{},
dns.TypePTR: struct{}{},
dns.TypeRRSIG: struct{}{},
dns.TypeSOA: struct{}{},
dns.TypeSRV: struct{}{},
dns.TypeTXT: struct{}{},
dns.TypeAAAA: {},
dns.TypeA: {},
dns.TypeCNAME: {},
dns.TypeDNSKEY: {},
dns.TypeDS: {},
dns.TypeMX: {},
dns.TypeNSEC3: {},
dns.TypeNSEC: {},
dns.TypeNS: {},
dns.TypePTR: {},
dns.TypeRRSIG: {},
dns.TypeSOA: {},
dns.TypeSRV: {},
dns.TypeTXT: {},
// Meta Qtypes
dns.TypeIXFR: struct{}{},
dns.TypeAXFR: struct{}{},
dns.TypeANY: struct{}{},
dns.TypeIXFR: {},
dns.TypeAXFR: {},
dns.TypeANY: {},
}

const other = "other"
4 changes: 2 additions & 2 deletions plugin/route53/route53_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ func (fakeRoute53) ListResourceRecordSetsPagesWithContext(_ aws.Context, in *rou
func TestRoute53(t *testing.T) {
ctx := context.Background()

r, err := New(ctx, fakeRoute53{}, map[string][]string{"bad.": []string{"0987654321"}}, &upstream.Upstream{})
r, err := New(ctx, fakeRoute53{}, map[string][]string{"bad.": {"0987654321"}}, &upstream.Upstream{})
if err != nil {
t.Fatalf("Failed to create Route53: %v", err)
}
if err = r.Run(ctx); err == nil {
t.Fatalf("Expected errors for zone bad.")
}

r, err = New(ctx, fakeRoute53{}, map[string][]string{"org.": []string{"1357986420", "1234567890"}, "gov.": []string{"Z098765432", "1234567890"}}, &upstream.Upstream{})
r, err = New(ctx, fakeRoute53{}, map[string][]string{"org.": {"1357986420", "1234567890"}, "gov.": {"Z098765432", "1234567890"}}, &upstream.Upstream{})
if err != nil {
t.Fatalf("Failed to create Route53: %v", err)
}
Expand Down