Fetcher returns fetch.Interface defined by conf. If no configuration source is set, this method returns nil, nil.
(ctx context.Context, httpClientProvider httpclient.Provider)
| 411 | // Fetcher returns fetch.Interface defined by conf. |
| 412 | // If no configuration source is set, this method returns nil, nil. |
| 413 | func (c InteropClient) Fetcher(ctx context.Context, httpClientProvider httpclient.Provider) (fetch.Interface, error) { |
| 414 | // TODO: Remove detection mechanism (https://github.com/TheThingsNetwork/lorawan-stack/issues/1450) |
| 415 | configSource := c.ConfigSource |
| 416 | if configSource == "" { |
| 417 | switch { |
| 418 | case c.Directory != "": |
| 419 | if stat, err := os.Stat(c.Directory); err == nil && stat.IsDir() { |
| 420 | configSource = "directory" |
| 421 | break |
| 422 | } |
| 423 | fallthrough |
| 424 | case c.URL != "": |
| 425 | configSource = "url" |
| 426 | case !c.Blob.IsZero(): |
| 427 | configSource = "blob" |
| 428 | } |
| 429 | } |
| 430 | switch configSource { |
| 431 | case "directory": |
| 432 | return fetch.FromFilesystem(c.Directory), nil |
| 433 | case "url": |
| 434 | httpClient, err := httpClientProvider.HTTPClient(ctx, httpclient.WithCache(true)) |
| 435 | if err != nil { |
| 436 | return nil, err |
| 437 | } |
| 438 | return fetch.FromHTTP(httpClient, c.URL) |
| 439 | case "blob": |
| 440 | b, err := c.BlobConfig.Bucket(ctx, c.Blob.Bucket, httpClientProvider) |
| 441 | if err != nil { |
| 442 | return nil, err |
| 443 | } |
| 444 | return fetch.FromBucket(ctx, b, c.Blob.Path), nil |
| 445 | default: |
| 446 | return nil, nil |
| 447 | } |
| 448 | } |
| 449 | |
| 450 | // SenderClientCA is the sender client CA configuration. |
| 451 | type SenderClientCA struct { |
nothing calls this directly
no test coverage detected