Skip to content

Commit

Permalink
πŸ› 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]>
  • Loading branch information
preslavgerchev committed Aug 12, 2024
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
Expand Up @@ -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.
Expand All @@ -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.
Expand Down

0 comments on commit 5ef9840

Please sign in to comment.