cachedMetadata returns the cached metadata provided it is not going to expire anytime soon. Caller must hold c.mu.
()
| 234 | // |
| 235 | // Caller must hold c.mu. |
| 236 | func (c *callCreds) cachedMetadata() map[string]string { |
| 237 | now := time.Now() |
| 238 | // If the cached token has not expired and the lifetime remaining on that |
| 239 | // token is greater than the minimum value we are willing to accept, go |
| 240 | // ahead and use it. |
| 241 | if c.tokenExpiry.After(now) && c.tokenExpiry.Sub(now) > minCachedTokenLifetime { |
| 242 | return c.tokenMetadata |
| 243 | } |
| 244 | return nil |
| 245 | } |
| 246 | |
| 247 | // constructRequest creates the STS request body in JSON based on the provided |
| 248 | // options. |