withFallback runs op against the current puller and, if an anonymous request is denied or rate-limited, rebuilds the puller with keychain credentials and retries once. Subsequent calls reuse the credentialed puller (and its cached token).
(op func(*remote.Puller) error)
| 233 | // retries once. Subsequent calls reuse the credentialed puller (and its cached |
| 234 | // token). |
| 235 | func (s *session) withFallback(op func(*remote.Puller) error) error { |
| 236 | err := op(s.puller) |
| 237 | if s.fellBack || !shouldRetryWithCredentials(err) { |
| 238 | return err |
| 239 | } |
| 240 | |
| 241 | if err := s.retryWithCredentials(); err != nil { |
| 242 | return err |
| 243 | } |
| 244 | return op(s.puller) |
| 245 | } |
| 246 | |
| 247 | func (s *session) retryWithCredentials() error { |
| 248 | if s.fellBack { |
no test coverage detected