From 5622de9fec4d459d5c2a8fc2fddd9c6d78119404 Mon Sep 17 00:00:00 2001 From: Jordan Krage Date: Wed, 15 Mar 2023 17:50:05 -0500 Subject: [PATCH] core/cmd: only run fallback API initializer when file not present (#8718) --- core/cmd/local_client.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/cmd/local_client.go b/core/cmd/local_client.go index 814afbe1ee7..e5887b903e5 100644 --- a/core/cmd/local_client.go +++ b/core/cmd/local_client.go @@ -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)