Retrieve returns the credentials value, returns no credentials(anonymous) if no credentials provider returned any value. If a provider is found with credentials, it will be cached and any calls to IsExpired() will return the expired state of the cached provider.
()
| 79 | // If a provider is found with credentials, it will be cached and any calls |
| 80 | // to IsExpired() will return the expired state of the cached provider. |
| 81 | func (c *Chain) Retrieve() (Value, error) { |
| 82 | for _, p := range c.Providers { |
| 83 | creds, _ := p.Retrieve() |
| 84 | // Always prioritize non-anonymous providers, if any. |
| 85 | if creds.AccessKeyID == "" && creds.SecretAccessKey == "" { |
| 86 | continue |
| 87 | } |
| 88 | c.curr = p |
| 89 | return creds, nil |
| 90 | } |
| 91 | // At this point we have exhausted all the providers and |
| 92 | // are left without any credentials return anonymous. |
| 93 | return Value{ |
| 94 | SignerType: SignatureAnonymous, |
| 95 | }, nil |
| 96 | } |
| 97 | |
| 98 | // IsExpired will returned the expired state of the currently cached provider |
| 99 | // if there is one. If there is no current provider, true will be returned. |