Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Do not panic if service account opts error out. #51

Merged
merged 1 commit into from
Aug 12, 2024

Conversation

preslavgerchev
Copy link
Contributor

@preslavgerchev preslavgerchev commented Aug 12, 2024

If the NewServiceAccountTokenSource errs out, we get a nil sa back. Trying to access sa.ApiEndpoint causes a panic. Reuse WithServiceAccount when calling WithServiceAccountFile since the only diff is we need to read the file first in the latter.

func WithServiceAccount(data []byte) ClientOption {
ts, sa, err := signer.NewServiceAccountTokenSource(data)
return withTokenSource{sa.ApiEndpoint, ts, err}
if err != nil {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ok for now. We should consider moving the parsing out and just take a the service account object directly.

@preslavgerchev preslavgerchev merged commit 5d14ca4 into main Aug 12, 2024
7 checks passed
@preslavgerchev preslavgerchev deleted the preslav/no-panic branch August 12, 2024 11:54
@github-actions github-actions bot locked and limited conversation to collaborators Aug 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants