From ccc1d321f762878ee43fa9d198c5795058e3c572 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 | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/option/option.go b/option/option.go index 74a2308..830c96d 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. @@ -84,7 +87,10 @@ func WithServiceAccountFile(filename string) 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} } // WithoutAuthentication returns a ClientOption that disables authentication.