github.com/grafana/pyroscope@v1.18.0/pkg/objstore/providers/gcs/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/gcs/bucket_client.go 3 // Provenance-includes-license: Apache-2.0 4 // Provenance-includes-copyright: The Cortex Authors. 5 6 package gcs 7 8 import ( 9 "context" 10 11 "github.com/go-kit/log" 12 "github.com/prometheus/common/model" 13 "github.com/thanos-io/objstore" 14 "github.com/thanos-io/objstore/exthttp" 15 "github.com/thanos-io/objstore/providers/gcs" 16 "gopkg.in/yaml.v3" 17 ) 18 19 // NewBucketClient creates a new GCS bucket client 20 func NewBucketClient(ctx context.Context, cfg Config, name string, logger log.Logger) (objstore.Bucket, error) { 21 bucketConfig := gcs.Config{ 22 Bucket: cfg.BucketName, 23 ServiceAccount: cfg.ServiceAccount.String(), 24 HTTPConfig: exthttp.HTTPConfig{ 25 IdleConnTimeout: model.Duration(cfg.HTTP.IdleConnTimeout), 26 ResponseHeaderTimeout: model.Duration(cfg.HTTP.ResponseHeaderTimeout), 27 InsecureSkipVerify: cfg.HTTP.InsecureSkipVerify, 28 TLSHandshakeTimeout: model.Duration(cfg.HTTP.TLSHandshakeTimeout), 29 ExpectContinueTimeout: model.Duration(cfg.HTTP.ExpectContinueTimeout), 30 MaxIdleConns: cfg.HTTP.MaxIdleConns, 31 MaxIdleConnsPerHost: cfg.HTTP.MaxIdleConnsPerHost, 32 MaxConnsPerHost: cfg.HTTP.MaxConnsPerHost, 33 }, 34 } 35 36 // Thanos currently doesn't support passing the config as is, but expects a YAML, 37 // so we're going to serialize it. 38 serialized, err := yaml.Marshal(bucketConfig) 39 if err != nil { 40 return nil, err 41 } 42 43 return gcs.NewBucket(ctx, logger, serialized, name, nil) 44 }