MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / Fetcher

Method Fetcher

pkg/config/shared.go:413–448  ·  view source on GitHub ↗

Fetcher returns fetch.Interface defined by conf. If no configuration source is set, this method returns nil, nil.

(ctx context.Context, httpClientProvider httpclient.Provider)

Source from the content-addressed store, hash-verified

411// Fetcher returns fetch.Interface defined by conf.
412// If no configuration source is set, this method returns nil, nil.
413func (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.
451type SenderClientCA struct {

Callers

nothing calls this directly

Implementers 2

joinServerHTTPClientpkg/interop/client.go
Clientpkg/interop/client.go

Calls 7

FromFilesystemFunction · 0.92
WithCacheFunction · 0.92
FromHTTPFunction · 0.92
FromBucketFunction · 0.92
BucketMethod · 0.80
IsZeroMethod · 0.65
HTTPClientMethod · 0.65

Tested by

no test coverage detected