diff options
author | 2019-03-18 15:17:46 +0800 | |
---|---|---|
committer | 2019-03-18 07:17:46 +0000 | |
commit | 440566152084f3d61789152d76461e25813cdc0b (patch) | |
tree | 97a9190e64cbc78a95483f33a4d029838588627a /plugin | |
parent | 287e280106e70660836664cca46ae7a0c7d311f0 (diff) | |
download | coredns-440566152084f3d61789152d76461e25813cdc0b.tar.gz coredns-440566152084f3d61789152d76461e25813cdc0b.tar.zst coredns-440566152084f3d61789152d76461e25813cdc0b.zip |
patch setup (#2675)
* patch setup
Use a more streamlined grammar
* fix break
No need to break out in this for loop
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/etcd/setup.go | 87 |
1 files changed, 40 insertions, 47 deletions
diff --git a/plugin/etcd/setup.go b/plugin/etcd/setup.go index 3dfe6a49a..3cf73377f 100644 --- a/plugin/etcd/setup.go +++ b/plugin/etcd/setup.go @@ -59,56 +59,49 @@ func etcdParse(c *caddy.Controller) (*Etcd, error) { etc.Zones[i] = plugin.Host(str).Normalize() } - if c.NextBlock() { - for { - switch c.Val() { - case "stubzones": - // ignored, remove later. - case "fallthrough": - etc.Fall.SetZonesFromArgs(c.RemainingArgs()) - case "debug": - /* it is a noop now */ - case "path": - if !c.NextArg() { - return &Etcd{}, c.ArgErr() - } - etc.PathPrefix = c.Val() - case "endpoint": - args := c.RemainingArgs() - if len(args) == 0 { - return &Etcd{}, c.ArgErr() - } - endpoints = args - case "upstream": - // check args != 0 and error in the future - c.RemainingArgs() // clear buffer - etc.Upstream = upstream.New() - case "tls": // cert key cacertfile - args := c.RemainingArgs() - tlsConfig, err = mwtls.NewTLSConfigFromArgs(args...) - if err != nil { - return &Etcd{}, err - } - case "credentials": - args := c.RemainingArgs() - if len(args) == 0 { - return &Etcd{}, c.ArgErr() - } - if len(args) != 2 { - return &Etcd{}, c.Errf("credentials requires 2 arguments, username and password") - } - username, password = args[0], args[1] - default: - if c.Val() != "}" { - return &Etcd{}, c.Errf("unknown property '%s'", c.Val()) - } + for c.NextBlock() { + switch c.Val() { + case "stubzones": + // ignored, remove later. + case "fallthrough": + etc.Fall.SetZonesFromArgs(c.RemainingArgs()) + case "debug": + /* it is a noop now */ + case "path": + if !c.NextArg() { + return &Etcd{}, c.ArgErr() } - - if !c.Next() { - break + etc.PathPrefix = c.Val() + case "endpoint": + args := c.RemainingArgs() + if len(args) == 0 { + return &Etcd{}, c.ArgErr() + } + endpoints = args + case "upstream": + // check args != 0 and error in the future + c.RemainingArgs() // clear buffer + etc.Upstream = upstream.New() + case "tls": // cert key cacertfile + args := c.RemainingArgs() + tlsConfig, err = mwtls.NewTLSConfigFromArgs(args...) + if err != nil { + return &Etcd{}, err + } + case "credentials": + args := c.RemainingArgs() + if len(args) == 0 { + return &Etcd{}, c.ArgErr() + } + if len(args) != 2 { + return &Etcd{}, c.Errf("credentials requires 2 arguments, username and password") + } + username, password = args[0], args[1] + default: + if c.Val() != "}" { + return &Etcd{}, c.Errf("unknown property '%s'", c.Val()) } } - } client, err := newEtcdClient(endpoints, tlsConfig, username, password) if err != nil { |