Skip to content

Commit

Permalink
PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
enocom committed Oct 12, 2022
1 parent c81783d commit 0742708
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
6 changes: 3 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -362,10 +362,10 @@ func parseConfig(cmd *Command, conf *proxy.Config, args []string) error {

if cmd.impersonationChain != "" {
accts := strings.Split(cmd.impersonationChain, ",")
conf.ImpersonateTarget = accts[0]
l := len(accts)
conf.ImpersonateTarget = accts[l-1]
// Assign delegates if the chain is more than one account.
if l := len(accts); l > 1 {
conf.ImpersonateTarget = accts[l-1]
if l > 1 {
conf.ImpersonateDelegates = accts[:l-1]
}
}
Expand Down
5 changes: 1 addition & 4 deletions internal/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,7 @@ func (c *Config) credentialsOpt(l cloudsql.Logger) (cloudsqlconn.Option, error)
impersonate.CredentialsConfig{
TargetPrincipal: c.ImpersonateTarget,
Delegates: c.ImpersonateDelegates,
Scopes: []string{
sqladmin.CloudPlatformScope,
sqladmin.SqlserviceAdminScope,
},
Scopes: []string{sqladmin.SqlserviceAdminScope},
},
iopts...,
)
Expand Down
4 changes: 1 addition & 3 deletions tests/connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (

"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/sqladmin/v1"
)

const connTestTimeout = time.Minute
Expand All @@ -36,8 +35,7 @@ const connTestTimeout = time.Minute
// that restores the original setup.
func removeAuthEnvVar(t *testing.T) (*oauth2.Token, string, func()) {
ts, err := google.DefaultTokenSource(context.Background(),
sqladmin.CloudPlatformScope,
sqladmin.SqlserviceAdminScope,
"https://www.googleapis.com/auth/cloud-platform",
)
if err != nil {
t.Errorf("failed to resolve token source: %v", err)
Expand Down

0 comments on commit 0742708

Please sign in to comment.