-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: add support for service account impersonation #192
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See if you can get rid of the redundant switch statement.
if c.ImpersonateTarget != "" { | ||
var iopts []option.ClientOption | ||
switch { | ||
case c.Token != "": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this switch statement from line 130-150 are much identical to lines 166-189. Could you somehow
combine those into a separate function?
iopts := c.withCredentialSource(l) // switch statement in here
if c.ImpersonateTarget != "" {
ts, err := impersonate.CredentialsTokenSource( ... iopts)
// ... error handling, etc
return alloydbconn.WithTokenSource(ts)
}
return iopts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are making significant changes to this PR we should make sure to update the Cloud SQL go connector as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this in the v2 proxy and port the change here.
We'll land this change in the Cloud SQL proxy and port it back over here.
This is a port of GoogleCloudPlatform/cloud-sql-proxy#1460.