github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/storage/bucket/azure/bucket_client.go (about)

     1  package azure
     2  
     3  import (
     4  	"github.com/go-kit/log"
     5  	"github.com/thanos-io/thanos/pkg/objstore"
     6  	"github.com/thanos-io/thanos/pkg/objstore/azure"
     7  	yaml "gopkg.in/yaml.v2"
     8  )
     9  
    10  func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
    11  	bucketConfig := azure.Config{
    12  		StorageAccountName: cfg.StorageAccountName,
    13  		StorageAccountKey:  cfg.StorageAccountKey.Value,
    14  		ContainerName:      cfg.ContainerName,
    15  		Endpoint:           cfg.Endpoint,
    16  		MaxRetries:         cfg.MaxRetries,
    17  	}
    18  
    19  	// Thanos currently doesn't support passing the config as is, but expects a YAML,
    20  	// so we're going to serialize it.
    21  	serialized, err := yaml.Marshal(bucketConfig)
    22  	if err != nil {
    23  		return nil, err
    24  	}
    25  
    26  	return azure.NewBucket(logger, serialized, name)
    27  }