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 GitHub
parent a346064eaf
commit cdd8f9fd82
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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...)
}
// 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
serverID := (*c.opts.Server).Options().Id
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))
}
// 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
if name := ctx.String("selector"); len(name) > 0 && (*c.opts.Selector).String() != 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 {
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
accSecret = acc.Secret