From 10c3e482b4407f700a85209b5b6c64543326e5e0 Mon Sep 17 00:00:00 2001 From: Joshua Casey Date: Wed, 7 Jun 2023 20:50:09 -0500 Subject: [PATCH] Prefer early return --- internal/issuer/issuer.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/internal/issuer/issuer.go b/internal/issuer/issuer.go index ef563e99..f4a392c5 100644 --- a/internal/issuer/issuer.go +++ b/internal/issuer/issuer.go @@ -1,4 +1,4 @@ -// Copyright 2021 the Pinniped contributors. All Rights Reserved. +// Copyright 2021-2023 the Pinniped contributors. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 package issuer @@ -42,11 +42,10 @@ func (c ClientCertIssuers) IssueClientCertPEM(username string, groups []string, for _, issuer := range c { certPEM, keyPEM, err := issuer.IssueClientCertPEM(username, groups, ttl) - if err != nil { - errs = append(errs, fmt.Errorf("%s failed to issue client cert: %w", issuer.Name(), err)) - continue + if err == nil { + return certPEM, keyPEM, nil } - return certPEM, keyPEM, nil + errs = append(errs, fmt.Errorf("%s failed to issue client cert: %w", issuer.Name(), err)) } if err := errors.NewAggregate(errs); err != nil {