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 ccc1d32
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 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 @@ -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.
Expand Down

0 comments on commit ccc1d32

Please sign in to comment.