From 5ef98405854afa3adc229d93a11c0f288ef34ff6 Mon Sep 17 00:00:00 2001 From: Preslav Date: Mon, 12 Aug 2024 13:43:38 +0300 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Do=20not=20panic=20if=20service?= =?UTF-8?q?=20account=20opts=20error=20out.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Preslav --- option/option.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/option/option.go b/option/option.go index 74a2308..53ce66c 100644 --- a/option/option.go +++ b/option/option.go @@ -73,7 +73,10 @@ func WithAPIToken(token string) ClientOption { // WithServiceAccount returns a ClientOption that specifies the credentials file to use. func WithServiceAccount(data []byte) ClientOption { ts, sa, err := signer.NewServiceAccountTokenSource(data) - return withTokenSource{sa.ApiEndpoint, ts, err} + if err != nil { + return withTokenSource{"", nil, err} + } + return withTokenSource{sa.ApiEndpoint, ts, nil} } // WithServiceAccountFile returns a ClientOption that specifies the credentials file to use. @@ -82,9 +85,7 @@ func WithServiceAccountFile(filename string) ClientOption { if err != nil { return withTokenSource{"", nil, err} } - - ts, sa, err := signer.NewServiceAccountTokenSource(data) - return withTokenSource{sa.ApiEndpoint, ts, err} + return WithServiceAccount(data) } // WithoutAuthentication returns a ClientOption that disables authentication.