mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
patch setup (#2675)
* patch setup Use a more streamlined grammar * fix break No need to break out in this for loop
This commit is contained in:
@@ -59,56 +59,49 @@ func etcdParse(c *caddy.Controller) (*Etcd, error) {
|
|||||||
etc.Zones[i] = plugin.Host(str).Normalize()
|
etc.Zones[i] = plugin.Host(str).Normalize()
|
||||||
}
|
}
|
||||||
|
|
||||||
if c.NextBlock() {
|
for c.NextBlock() {
|
||||||
for {
|
switch c.Val() {
|
||||||
switch c.Val() {
|
case "stubzones":
|
||||||
case "stubzones":
|
// ignored, remove later.
|
||||||
// ignored, remove later.
|
case "fallthrough":
|
||||||
case "fallthrough":
|
etc.Fall.SetZonesFromArgs(c.RemainingArgs())
|
||||||
etc.Fall.SetZonesFromArgs(c.RemainingArgs())
|
case "debug":
|
||||||
case "debug":
|
/* it is a noop now */
|
||||||
/* it is a noop now */
|
case "path":
|
||||||
case "path":
|
if !c.NextArg() {
|
||||||
if !c.NextArg() {
|
return &Etcd{}, c.ArgErr()
|
||||||
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())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
etc.PathPrefix = c.Val()
|
||||||
if !c.Next() {
|
case "endpoint":
|
||||||
break
|
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)
|
client, err := newEtcdClient(endpoints, tlsConfig, username, password)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user