Fetcher returns fetch.Interface defined by conf. If no configuration source is set, this method returns nil, nil.
( ctx context.Context, blobConf BlobConfig, httpClientProvider httpclient.Provider, )
| 586 | // Fetcher returns fetch.Interface defined by conf. |
| 587 | // If no configuration source is set, this method returns nil, nil. |
| 588 | func (c RateLimiting) Fetcher( |
| 589 | ctx context.Context, blobConf BlobConfig, httpClientProvider httpclient.Provider, |
| 590 | ) (fetch.Interface, error) { |
| 591 | switch c.ConfigSource { |
| 592 | case "directory": |
| 593 | return fetch.FromFilesystem(c.Directory), nil |
| 594 | case "url": |
| 595 | httpClient, err := httpClientProvider.HTTPClient(ctx, httpclient.WithCache(true)) |
| 596 | if err != nil { |
| 597 | return nil, err |
| 598 | } |
| 599 | return fetch.FromHTTP(httpClient, c.URL) |
| 600 | case "blob": |
| 601 | b, err := blobConf.Bucket(ctx, c.Blob.Bucket, httpClientProvider) |
| 602 | if err != nil { |
| 603 | return nil, err |
| 604 | } |
| 605 | return fetch.FromBucket(ctx, b, c.Blob.Path), nil |
| 606 | default: |
| 607 | return nil, nil |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | // MTLSAuthConfig contains the configuration for mTLS authentication. |
| 612 | type MTLSAuthConfig struct { |
no test coverage detected