Remove unnecessary change

This commit is contained in:
Ben Toogood 2020-05-14 13:32:42 +01:00
parent c220686c29
commit 83e9c1fad2

View File

@ -525,6 +525,22 @@ func (c *cmd) Before(ctx *cli.Context) error {
*c.opts.Profile = p() *c.opts.Profile = p()
} }
// Set the client
if name := ctx.String("client"); len(name) > 0 {
// only change if we have the client and type differs
if cl, ok := c.opts.Clients[name]; ok && (*c.opts.Client).String() != name {
*c.opts.Client = cl()
}
}
// Set the server
if name := ctx.String("server"); len(name) > 0 {
// only change if we have the server and type differs
if s, ok := c.opts.Servers[name]; ok && (*c.opts.Server).String() != name {
*c.opts.Server = s()
}
}
// Set the broker // Set the broker
if name := ctx.String("broker"); len(name) > 0 && (*c.opts.Broker).String() != name { if name := ctx.String("broker"); len(name) > 0 && (*c.opts.Broker).String() != name {
b, ok := c.opts.Brokers[name] b, ok := c.opts.Brokers[name]
@ -584,22 +600,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
clientOpts = append(clientOpts, client.Transport(*c.opts.Transport)) clientOpts = append(clientOpts, client.Transport(*c.opts.Transport))
} }
// Set the client
if name := ctx.String("client"); len(name) > 0 {
// only change if we have the client and type differs
if cl, ok := c.opts.Clients[name]; ok && (*c.opts.Client).String() != name {
*c.opts.Client = cl()
}
}
// Set the server
if name := ctx.String("server"); len(name) > 0 {
// only change if we have the server and type differs
if s, ok := c.opts.Servers[name]; ok && (*c.opts.Server).String() != name {
*c.opts.Server = s()
}
}
// Parse the server options // Parse the server options
metadata := make(map[string]string) metadata := make(map[string]string)
for _, d := range ctx.StringSlice("server_metadata") { for _, d := range ctx.StringSlice("server_metadata") {