GetWithContext returns the credentials value, or error if the credentials Value failed to be retrieved. Will return the cached credentials Value if it has not expired. If the credentials Value has expired the Provider's Retrieve() will be called to refresh the credentials. If Credentials.Expire()
(cc *CredContext)
| 190 | // If Credentials.Expire() was called the credentials Value will be force |
| 191 | // expired, and the next call to Get() will cause them to be refreshed. |
| 192 | func (c *Credentials) GetWithContext(cc *CredContext) (Value, error) { |
| 193 | if c == nil { |
| 194 | return Value{}, nil |
| 195 | } |
| 196 | if cc == nil { |
| 197 | cc = defaultCredContext |
| 198 | } |
| 199 | |
| 200 | c.Lock() |
| 201 | defer c.Unlock() |
| 202 | |
| 203 | if c.isExpired() { |
| 204 | creds, err := c.provider.RetrieveWithCredContext(cc) |
| 205 | if err != nil { |
| 206 | return Value{}, err |
| 207 | } |
| 208 | c.creds = creds |
| 209 | c.forceRefresh = false |
| 210 | } |
| 211 | |
| 212 | return c.creds, nil |
| 213 | } |
| 214 | |
| 215 | // Expire expires the credentials and forces them to be retrieved on the |
| 216 | // next call to Get(). |