Initialize selector before we make an auth.Generate call (#1693)

This commit is contained in:
Janos Dobronszki 2020-06-09 12:47:31 +02:00 committed by Dominic Wong
parent aec27be9b4
commit 00b76e0a64
2 changed files with 23 additions and 23 deletions

View File

@ -580,6 +580,28 @@ func (c *cmd) Before(ctx *cli.Context) error {
(*c.opts.Auth).Init(authOpts...) (*c.opts.Auth).Init(authOpts...)
} }
// Set the registry
if name := ctx.String("registry"); len(name) > 0 && (*c.opts.Registry).String() != name {
r, ok := c.opts.Registries[name]
if !ok {
return fmt.Errorf("Registry %s not found", name)
}
*c.opts.Registry = r(registrySrv.WithClient(microClient))
serverOpts = append(serverOpts, server.Registry(*c.opts.Registry))
clientOpts = append(clientOpts, client.Registry(*c.opts.Registry))
if err := (*c.opts.Selector).Init(selector.Registry(*c.opts.Registry)); err != nil {
logger.Fatalf("Error configuring registry: %v", err)
}
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
if err := (*c.opts.Broker).Init(broker.Registry(*c.opts.Registry)); err != nil {
logger.Fatalf("Error configuring broker: %v", err)
}
}
// generate the services auth account // generate the services auth account
serverID := (*c.opts.Server).Options().Id serverID := (*c.opts.Server).Options().Id
if err := authutil.Generate(serverID, c.App().Name, (*c.opts.Auth)); err != nil { if err := authutil.Generate(serverID, c.App().Name, (*c.opts.Auth)); err != nil {
@ -608,28 +630,6 @@ func (c *cmd) Before(ctx *cli.Context) error {
clientOpts = append(clientOpts, client.Broker(*c.opts.Broker)) clientOpts = append(clientOpts, client.Broker(*c.opts.Broker))
} }
// Set the registry
if name := ctx.String("registry"); len(name) > 0 && (*c.opts.Registry).String() != name {
r, ok := c.opts.Registries[name]
if !ok {
return fmt.Errorf("Registry %s not found", name)
}
*c.opts.Registry = r(registrySrv.WithClient(microClient))
serverOpts = append(serverOpts, server.Registry(*c.opts.Registry))
clientOpts = append(clientOpts, client.Registry(*c.opts.Registry))
if err := (*c.opts.Selector).Init(selector.Registry(*c.opts.Registry)); err != nil {
logger.Fatalf("Error configuring registry: %v", err)
}
clientOpts = append(clientOpts, client.Selector(*c.opts.Selector))
if err := (*c.opts.Broker).Init(broker.Registry(*c.opts.Registry)); err != nil {
logger.Fatalf("Error configuring broker: %v", err)
}
}
// Set the selector // Set the selector
if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name { if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != name {
s, ok := c.opts.Selectors[name] s, ok := c.opts.Selectors[name]

View File

@ -28,7 +28,7 @@ func Generate(id string, name string, a auth.Auth) error {
if err != nil { if err != nil {
return err return err
} }
logger.Infof("Auth [%v] Authenticated as %v issued by %v", a, name, acc.Issuer) logger.Debugf("Auth [%v] Authenticated as %v issued by %v", a, name, acc.Issuer)
accID = acc.ID accID = acc.ID
accSecret = acc.Secret accSecret = acc.Secret