MCPcopy
hub / github.com/kubernetes/client-go / newCachedTokenSource

Function newCachedTokenSource

plugin/pkg/client/auth/gcp/gcp.go:197–212  ·  view source on GitHub ↗
(accessToken, expiry string, persister restclient.AuthProviderConfigPersister, ts oauth2.TokenSource, cache map[string]string)

Source from the content-addressed store, hash-verified

195}
196
197func newCachedTokenSource(accessToken, expiry string, persister restclient.AuthProviderConfigPersister, ts oauth2.TokenSource, cache map[string]string) (*cachedTokenSource, error) {
198 var expiryTime time.Time
199 if parsedTime, err := time.Parse(time.RFC3339Nano, expiry); err == nil {
200 expiryTime = parsedTime
201 }
202 if cache == nil {
203 cache = make(map[string]string)
204 }
205 return &cachedTokenSource{
206 source: ts,
207 accessToken: accessToken,
208 expiry: expiryTime,
209 persister: persister,
210 cache: cache,
211 }, nil
212}
213
214func (t *cachedTokenSource) Token() (*oauth2.Token, error) {
215 tok := t.cachedToken()

Callers 3

newGCPAuthProviderFunction · 0.85
TestCachedTokenSourceFunction · 0.85

Calls 1

ParseMethod · 0.45

Tested by 2

TestCachedTokenSourceFunction · 0.68