Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Do not panic if service account opts error out.
Browse files Browse the repository at this point in the history
Signed-off-by: Preslav <[email protected]>
preslavgerchev committed Aug 12, 2024

Verified

This commit was signed with the committer’s verified signature.
preslavgerchev Preslav Gerchev
1 parent 26ac759 commit 5ef9840
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions option/option.go
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 5ef9840

Please sign in to comment.