config/cmd: fix selector setup bug (#1723)

This commit is contained in:
ben-toogood 2020-06-19 13:11:48 +01:00 committed by GitHub
parent ece02a6d21
commit 2b889087bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -692,6 +692,21 @@ func (c *cmd) Before(ctx *cli.Context) error {
}
}
// Set the selector
if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name {
s, ok := c.opts.Selectors[name]
if !ok {
logger.Fatalf("Selector %s not found", name)
}
*c.opts.Selector = s(selectorOpts...)
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
} else if len(selectorOpts) > 0 {
if err := (*c.opts.Selector).Init(selectorOpts...); err != nil {
logger.Fatalf("Error configuring selctor: %v", err)
}
}
// generate the services auth account.
// todo: move this so it only runs for new services
serverID := (*c.opts.Server).Options().Id
@ -725,21 +740,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
}
}
// Set the selector
if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name {
s, ok := c.opts.Selectors[name]
if !ok {
logger.Fatalf("Selector %s not found", name)
}
*c.opts.Selector = s(selectorOpts...)
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
} else if len(selectorOpts) > 0 {
if err := (*c.opts.Selector).Init(selectorOpts...); err != nil {
logger.Fatalf("Error configuring selctor: %v", err)
}
}
// Setup the transport options
var transportOpts []transport.Option
if len(ctx.String("transport_address")) > 0 {