github.com/grafana/pyroscope@v1.18.0/pkg/objstore/providers/azure/bucket_client.go (about)

     1  // SPDX-License-Identifier: AGPL-3.0-only
     2  // Provenance-includes-location: https://github.com/cortexproject/cortex/blob/master/pkg/storage/bucket/azure/bucket_client.go
     3  // Provenance-includes-license: Apache-2.0
     4  // Provenance-includes-copyright: The Cortex Authors.
     5  
     6  package azure
     7  
     8  import (
     9  	"net/http"
    10  
    11  	"github.com/go-kit/log"
    12  	"github.com/thanos-io/objstore"
    13  	"github.com/thanos-io/objstore/providers/azure"
    14  )
    15  
    16  func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
    17  	return newBucketClient(cfg, name, logger, azure.NewBucketWithConfig)
    18  }
    19  
    20  func newBucketClient(cfg Config, name string, logger log.Logger, factory func(log.Logger, azure.Config, string, func(http.RoundTripper) http.RoundTripper) (*azure.Bucket, error)) (objstore.Bucket, error) {
    21  	// Start with default config to make sure that all parameters are set to sensible values, especially
    22  	// HTTP Config field.
    23  	bucketConfig := azure.DefaultConfig
    24  	bucketConfig.AzTenantID = cfg.AzTenantID
    25  	bucketConfig.ClientID = cfg.ClientID
    26  	bucketConfig.ClientSecret = cfg.ClientSecret.String()
    27  	bucketConfig.StorageAccountName = cfg.StorageAccountName
    28  	bucketConfig.StorageAccountKey = cfg.StorageAccountKey.String()
    29  	bucketConfig.StorageConnectionString = cfg.StorageConnectionString.String()
    30  	bucketConfig.ContainerName = cfg.ContainerName
    31  	bucketConfig.MaxRetries = cfg.MaxRetries
    32  	bucketConfig.UserAssignedID = cfg.UserAssignedID
    33  
    34  	// do not delay retries
    35  	bucketConfig.PipelineConfig.RetryDelay = -1
    36  
    37  	if cfg.Endpoint != "" {
    38  		// azure.DefaultConfig has the default Endpoint, overwrite it only if a different one was explicitly provided.
    39  		bucketConfig.Endpoint = cfg.Endpoint
    40  	}
    41  
    42  	return factory(logger, bucketConfig, name, nil)
    43  }