Skip to content

Conversation

@enocom
Copy link
Member

@enocom enocom commented Dec 7, 2022

@enocom enocom requested a review from a team December 7, 2022 19:50
hessjcg
hessjcg previously requested changes Dec 7, 2022
Copy link
Contributor

@hessjcg hessjcg left a 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 != "":
Copy link
Contributor

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
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
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