github.com/grafana/pyroscope@v1.18.0/pkg/objstore/providers/swift/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/swift/bucket_client.go 3 // Provenance-includes-license: Apache-2.0 4 // Provenance-includes-copyright: The Cortex Authors. 5 6 package swift 7 8 import ( 9 "github.com/go-kit/log" 10 "github.com/prometheus/common/model" 11 "github.com/thanos-io/objstore" 12 "github.com/thanos-io/objstore/providers/swift" 13 "gopkg.in/yaml.v3" 14 ) 15 16 // NewBucketClient creates a new Swift bucket client 17 func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) { 18 bucketConfig := swift.Config{ 19 AuthVersion: cfg.AuthVersion, 20 AuthUrl: cfg.AuthURL, 21 Username: cfg.Username, 22 UserDomainName: cfg.UserDomainName, 23 UserDomainID: cfg.UserDomainID, 24 UserId: cfg.UserID, 25 Password: cfg.Password.String(), 26 DomainId: cfg.DomainID, 27 DomainName: cfg.DomainName, 28 ProjectID: cfg.ProjectID, 29 ProjectName: cfg.ProjectName, 30 ProjectDomainID: cfg.ProjectDomainID, 31 ProjectDomainName: cfg.ProjectDomainName, 32 RegionName: cfg.RegionName, 33 ContainerName: cfg.ContainerName, 34 Retries: cfg.MaxRetries, 35 ConnectTimeout: model.Duration(cfg.ConnectTimeout), 36 Timeout: model.Duration(cfg.RequestTimeout), 37 38 // Hard-coded defaults. 39 ChunkSize: swift.DefaultConfig.ChunkSize, 40 UseDynamicLargeObjects: false, 41 } 42 43 // Thanos currently doesn't support passing the config as is, but expects a YAML, 44 // so we're going to serialize it. 45 serialized, err := yaml.Marshal(bucketConfig) 46 if err != nil { 47 return nil, err 48 } 49 50 return swift.NewContainer(logger, serialized, nil) 51 }