plugin/metadata: some cleanups (#1906)

* plugin/metadata: some cleanups

Name to provider.go as that's what being defined right now in the file.
Use request.Request because that's done in variables.go anyway. Name the
main storage M, because there is no further meaning behind.

Remove superfluous methods

Signed-off-by: Miek Gieben <miek@miek.nl>

* Fix test

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben 2018-06-29 15:03:25 +01:00 committed by GitHub
parent e6c00f39f1
commit 2fd31cd3e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 53 additions and 58 deletions

View file

@ -5,6 +5,7 @@ import (
"testing"
"github.com/coredns/coredns/plugin/test"
"github.com/coredns/coredns/request"
"github.com/miekg/dns"
)
@ -20,12 +21,12 @@ func (m testProvider) MetadataVarNames() []string {
return keys
}
func (m testProvider) Metadata(ctx context.Context, w dns.ResponseWriter, r *dns.Msg, key string) (val interface{}, ok bool) {
func (m testProvider) Metadata(ctx context.Context, state request.Request, key string) (val interface{}, ok bool) {
value, ok := m[key]
return value, ok
}
// testHandler implements plugin.Handler
// testHandler implements plugin.Handler.
type testHandler struct{ ctx context.Context }
func (m *testHandler) Name() string { return "testHandler" }
@ -35,7 +36,7 @@ func (m *testHandler) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns
return 0, nil
}
func TestMetadataServDns(t *testing.T) {
func TestMetadataServeDNS(t *testing.T) {
expectedMetadata := []testProvider{
testProvider{"testkey1": "testvalue1"},
testProvider{"testkey2": 2, "testkey3": "testvalue3"},
@ -45,9 +46,8 @@ func TestMetadataServDns(t *testing.T) {
for _, e := range expectedMetadata {
providers = append(providers, e)
}
// Fake handler which stores the resulting context
next := &testHandler{}
next := &testHandler{} // fake handler which stores the resulting context
metadata := Metadata{
Zones: []string{"."},
Providers: providers,