github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/pkg/storage/bucket/azure/bucket_client.go (about)

     1  package azure
     2  
     3  import (
     4  	"github.com/go-kit/log"
     5  	"github.com/prometheus/common/model"
     6  	"github.com/thanos-io/thanos/pkg/objstore"
     7  	"github.com/thanos-io/thanos/pkg/objstore/azure"
     8  	yaml "gopkg.in/yaml.v2"
     9  )
    10  
    11  func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
    12  	bucketConfig := azure.Config{
    13  		StorageAccountName: cfg.StorageAccountName,
    14  		StorageAccountKey:  cfg.StorageAccountKey.String(),
    15  		ContainerName:      cfg.ContainerName,
    16  		Endpoint:           cfg.Endpoint,
    17  		MaxRetries:         cfg.MaxRetries,
    18  		HTTPConfig: azure.HTTPConfig{
    19  			IdleConnTimeout:       model.Duration(cfg.IdleConnTimeout),
    20  			ResponseHeaderTimeout: model.Duration(cfg.ResponseHeaderTimeout),
    21  			InsecureSkipVerify:    cfg.InsecureSkipVerify,
    22  			TLSHandshakeTimeout:   model.Duration(cfg.TLSHandshakeTimeout),
    23  			ExpectContinueTimeout: model.Duration(cfg.ExpectContinueTimeout),
    24  			MaxIdleConns:          cfg.MaxIdleConns,
    25  			MaxIdleConnsPerHost:   cfg.MaxIdleConnsPerHost,
    26  			MaxConnsPerHost:       cfg.MaxConnsPerHost,
    27  		},
    28  	}
    29  
    30  	// Thanos currently doesn't support passing the config as is, but expects a YAML,
    31  	// so we're going to serialize it.
    32  	serialized, err := yaml.Marshal(bucketConfig)
    33  	if err != nil {
    34  		return nil, err
    35  	}
    36  
    37  	return azure.NewBucket(logger, serialized, name)
    38  }