Skip to content

Commit 0742708

Browse files
committed
PR comments
1 parent c81783d commit 0742708

File tree

3 files changed

+5
-10
lines changed

3 files changed

+5
-10
lines changed

cmd/root.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -362,10 +362,10 @@ func parseConfig(cmd *Command, conf *proxy.Config, args []string) error {
362362

363363
if cmd.impersonationChain != "" {
364364
accts := strings.Split(cmd.impersonationChain, ",")
365-
conf.ImpersonateTarget = accts[0]
365+
l := len(accts)
366+
conf.ImpersonateTarget = accts[l-1]
366367
// Assign delegates if the chain is more than one account.
367-
if l := len(accts); l > 1 {
368-
conf.ImpersonateTarget = accts[l-1]
368+
if l > 1 {
369369
conf.ImpersonateDelegates = accts[:l-1]
370370
}
371371
}

internal/proxy/proxy.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,7 @@ func (c *Config) credentialsOpt(l cloudsql.Logger) (cloudsqlconn.Option, error)
231231
impersonate.CredentialsConfig{
232232
TargetPrincipal: c.ImpersonateTarget,
233233
Delegates: c.ImpersonateDelegates,
234-
Scopes: []string{
235-
sqladmin.CloudPlatformScope,
236-
sqladmin.SqlserviceAdminScope,
237-
},
234+
Scopes: []string{sqladmin.SqlserviceAdminScope},
238235
},
239236
iopts...,
240237
)

tests/connection_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626

2727
"golang.org/x/oauth2"
2828
"golang.org/x/oauth2/google"
29-
"google.golang.org/api/sqladmin/v1"
3029
)
3130

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

0 commit comments

Comments
 (0)