diff --git a/cmd/argocd/commands/headless/headless.go b/cmd/argocd/commands/headless/headless.go index b375dfdc161e0..070d9c9c83bcb 100644 --- a/cmd/argocd/commands/headless/headless.go +++ b/cmd/argocd/commands/headless/headless.go @@ -142,7 +142,10 @@ func testAPI(ctx context.Context, clientOpts *apiclient.ClientOptions) error { } defer io.Close(closer) _, err = versionClient.Version(ctx, &empty.Empty{}) - return fmt.Errorf("failed to get version: %w", err) + if err != nil { + return fmt.Errorf("failed to get version: %w", err) + } + return nil } // MaybeStartLocalServer allows executing command in a headless mode. If we're in core mode, starts the Argo CD API @@ -249,7 +252,10 @@ func MaybeStartLocalServer(ctx context.Context, clientOpts *apiclient.ClientOpti } time.Sleep(time.Second) } - return fmt.Errorf("all retries failed: %w", err) + if err != nil { + return fmt.Errorf("all retries failed: %w", err) + } + return nil } // NewClientOrDie creates a new API client from a set of config options, or fails fatally if the new client creation fails.