Skip to content

feat: add support for service account impersonation - #192

Merged
enocom merged 5 commits into
mainfrom
impersonation
Dec 7, 2022
Merged

enocom merged 5 commits into
mainfrom
impersonation

Conversation

@enocom

@enocom enocom commented Dec 7, 2022

Copy link
Copy Markdown
Member

@enocom
enocom requested a review from a team December 7, 2022 19:50
Comment thread internal/proxy/proxy.go
hessjcg
hessjcg previously requested changes Dec 7, 2022

@hessjcg hessjcg left a comment

Copy link
Copy Markdown
Member

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.

Comment thread internal/proxy/proxy.go
if c.ImpersonateTarget != "" {
var iopts []option.ClientOption
switch {
case c.Token != "":

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Member Author

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.

@enocom
enocom dismissed hessjcg’s stale review December 7, 2022 22:20

We'll land this change in the Cloud SQL proxy and port it back over here.

@enocom
enocom merged commit de15073 into main Dec 7, 2022
@enocom
enocom deleted the impersonation branch December 7, 2022 22:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants