github.com/muhammadn/cortex@v1.9.1-0.20220510110439-46bb7000d03d/pkg/storage/bucket/gcs/bucket_client.go (about) 1 package gcs 2 3 import ( 4 "context" 5 6 "github.com/go-kit/log" 7 "github.com/thanos-io/thanos/pkg/objstore" 8 "github.com/thanos-io/thanos/pkg/objstore/gcs" 9 yaml "gopkg.in/yaml.v2" 10 ) 11 12 // NewBucketClient creates a new GCS bucket client 13 func NewBucketClient(ctx context.Context, cfg Config, name string, logger log.Logger) (objstore.Bucket, error) { 14 bucketConfig := gcs.Config{ 15 Bucket: cfg.BucketName, 16 ServiceAccount: cfg.ServiceAccount.Value, 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 gcs.NewBucket(ctx, logger, serialized, name) 27 }