Skip to content

Commit

Permalink
πŸ› Do not panic if service account opts error out. (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Preslav <[email protected]>
  • Loading branch information
preslavgerchev authored Aug 12, 2024
1 parent 287fadb commit 5d14ca4
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions option/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,13 @@ func WithAPIToken(token string) ClientOption {
return withTokenSource{"", src, nil}
}

// WithServiceAccount returns a ClientOption that specifies the credentials file to use.
// WithServiceAccount returns a ClientOption that specifies the credentials 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 5d14ca4

Please sign in to comment.