Skip to content

Commit

Permalink
core/cmd: only run fallback API initializer when file not present (#8718
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jmank88 authored Mar 15, 2023
1 parent cd6e428 commit 5622de9
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions core/cmd/local_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,16 @@ func (cli *Client) runNode(c *clipkg.Context) error {
}

var user sessions.User
if _, err = NewFileAPIInitializer(c.String("api")).Initialize(sessionORM, lggr); err != nil && !errors.Is(err, ErrNoCredentialFile) {
return errors.Wrap(err, "error creating api initializer")
}
if user, err = cli.FallbackAPIInitializer.Initialize(sessionORM, lggr); err != nil {
if errors.Is(err, ErrorNoAPICredentialsAvailable) {
return errors.WithStack(err)
if user, err = NewFileAPIInitializer(c.String("api")).Initialize(sessionORM, lggr); err != nil {
if !errors.Is(err, ErrNoCredentialFile) {
return errors.Wrap(err, "error creating api initializer")
}
if user, err = cli.FallbackAPIInitializer.Initialize(sessionORM, lggr); err != nil {
if errors.Is(err, ErrorNoAPICredentialsAvailable) {
return errors.WithStack(err)
}
return errors.Wrap(err, "error creating fallback initializer")
}
return errors.Wrap(err, "error creating fallback initializer")
}

lggr.Info("API exposed for user ", user.Email)
Expand Down

0 comments on commit 5622de9

Please sign in to comment.