refactor: make impersonateTokenSource struct public

to impersonate the service account from the JSON config file, the existing impersonation mechanism can be reused.

Updates #515
This commit is contained in:
guillaume blaquiere
2021-08-23 10:52:40 +02:00
parent a3dd13af1f
commit 121de73b38
2 changed files with 15 additions and 15 deletions

View File

@@ -124,11 +124,11 @@ func (c *Config) tokenSource(ctx context.Context, tokenURLValidPats []*regexp.Re
}
scopes := c.Scopes
ts.conf.Scopes = []string{"https://www.googleapis.com/auth/cloud-platform"}
imp := impersonateTokenSource{
ctx: ctx,
url: c.ServiceAccountImpersonationURL,
scopes: scopes,
ts: oauth2.ReuseTokenSource(nil, ts),
imp := ImpersonateTokenSource{
Ctx: ctx,
Url: c.ServiceAccountImpersonationURL,
Scopes: scopes,
Ts: oauth2.ReuseTokenSource(nil, ts),
}
return oauth2.ReuseTokenSource(nil, imp), nil
}