Publish metadata from kubernetes plugin (#2829)

* Publish metadata from kubernetes plugin

* stickler fix

* Add a couple tests

* Add metadata section to README

* Update plugin/kubernetes/README.md

Co-Authored-By: Chris O'Haver <cohaver@infoblox.com>

* Address nit
This commit is contained in:
John Belamaric
2019-06-09 00:10:57 -07:00
committed by Miek Gieben
parent a1c97f82a6
commit ffcd2f61cf
6 changed files with 218 additions and 6 deletions

View File

@@ -20,10 +20,15 @@ type Metadata struct {
// Name implements the Handler interface.
func (m *Metadata) Name() string { return "metadata" }
// ContextWithMetadata is exported for use by provider tests
func ContextWithMetadata(ctx context.Context) context.Context {
return context.WithValue(ctx, key{}, md{})
}
// ServeDNS implements the plugin.Handler interface.
func (m *Metadata) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error) {
ctx = context.WithValue(ctx, key{}, md{})
ctx = ContextWithMetadata(ctx)
state := request.Request{W: w, Req: r}
if plugin.Zones(m.Zones).Matches(state.Name()) != "" {