From acd0b73a49d9dc4271b5d953c2f5de18d1eb5a64 Mon Sep 17 00:00:00 2001 From: Miek Gieben Date: Thu, 16 Jan 2020 07:15:09 +0100 Subject: [PATCH] Add more options to the plugin Signed-off-by: Miek Gieben --- plugin/traffic/README.md | 4 ++-- plugin/traffic/setup.go | 11 ++++++++--- plugin/traffic/traffic.go | 3 ++- plugin/traffic/xds/client.go | 2 +- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/plugin/traffic/README.md b/plugin/traffic/README.md index c15bda016..18aeb5705 100644 --- a/plugin/traffic/README.md +++ b/plugin/traffic/README.md @@ -39,11 +39,11 @@ The extended syntax (not implemented; everything is hard-coded at the moment): ~~~ traffic { server grpc://dsdsd - id ID + node ID } ~~~ -* id **ID** is how *traffic* identifies itself to the control plane. +* node **ID** is how *traffic* identifies itself to the control plane. This defaults to `coredns`. ## Examples diff --git a/plugin/traffic/setup.go b/plugin/traffic/setup.go index eb203a3e0..946101a7d 100644 --- a/plugin/traffic/setup.go +++ b/plugin/traffic/setup.go @@ -51,13 +51,18 @@ func setup(c *caddy.Controller) error { return nil } -func parse(c *caddy.Controller) error { +func parse(c *caddy.Controller) (*Traffic, error) { for c.Next() { args := c.RemainingArgs() if len(args) != 0 { - return c.ArgErr() + return nil, c.ArgErr() } + for c.NextBlock() { + switch c.Val() { + case "id": + } + } } - return nil + return nil, nil } diff --git a/plugin/traffic/traffic.go b/plugin/traffic/traffic.go index e1ff156fe..958fb219f 100644 --- a/plugin/traffic/traffic.go +++ b/plugin/traffic/traffic.go @@ -14,11 +14,12 @@ import ( // Traffic is a plugin that load balances according to assignments. type Traffic struct { c *xds.Client + id string Next plugin.Handler } // New returns a pointer to a new and initialized Traffic. -func New() (*Traffic, error) { +func New(addr, node string) (*Traffic, error) { c, err := xds.New(":18000", "mycoredns") if err != nil { return nil, err diff --git a/plugin/traffic/xds/client.go b/plugin/traffic/xds/client.go index d8dae31fc..bbf92d586 100644 --- a/plugin/traffic/xds/client.go +++ b/plugin/traffic/xds/client.go @@ -54,7 +54,7 @@ type Client struct { // New returns a new client that's dialed to addr using node as the local identifier. func New(addr, node string) (*Client, error) { - // todo credentials + // todo credentials! opts := []grpc.DialOption{grpc.WithInsecure()} cc, err := grpc.Dial(addr, opts...) if err != nil {