From 5ca06849e719b9a3b3f6d42e70248b04b301a6d4 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Thu, 19 Dec 2024 18:13:32 +0900 Subject: [PATCH] refactor bucket client to pass config directly Signed-off-by: SungJin1212 --- pkg/storage/bucket/azure/bucket_client.go | 10 +--------- pkg/storage/bucket/gcs/bucket_client.go | 10 +--------- pkg/storage/bucket/swift/bucket_client.go | 10 +--------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/pkg/storage/bucket/azure/bucket_client.go b/pkg/storage/bucket/azure/bucket_client.go index 60dd017b04..d01a272819 100644 --- a/pkg/storage/bucket/azure/bucket_client.go +++ b/pkg/storage/bucket/azure/bucket_client.go @@ -8,7 +8,6 @@ import ( "github.com/thanos-io/objstore" "github.com/thanos-io/objstore/exthttp" "github.com/thanos-io/objstore/providers/azure" - yaml "gopkg.in/yaml.v2" ) func NewBucketClient(cfg Config, hedgedRoundTripper func(rt http.RoundTripper) http.RoundTripper, name string, logger log.Logger) (objstore.Bucket, error) { @@ -32,12 +31,5 @@ func NewBucketClient(cfg Config, hedgedRoundTripper func(rt http.RoundTripper) h }, } - // Thanos currently doesn't support passing the config as is, but expects a YAML, - // so we're going to serialize it. - serialized, err := yaml.Marshal(bucketConfig) - if err != nil { - return nil, err - } - - return azure.NewBucket(logger, serialized, name, hedgedRoundTripper) + return azure.NewBucketWithConfig(logger, bucketConfig, name, hedgedRoundTripper) } diff --git a/pkg/storage/bucket/gcs/bucket_client.go b/pkg/storage/bucket/gcs/bucket_client.go index 1ef0202804..d5a08f4653 100644 --- a/pkg/storage/bucket/gcs/bucket_client.go +++ b/pkg/storage/bucket/gcs/bucket_client.go @@ -7,7 +7,6 @@ import ( "github.com/go-kit/log" "github.com/thanos-io/objstore" "github.com/thanos-io/objstore/providers/gcs" - yaml "gopkg.in/yaml.v2" ) // NewBucketClient creates a new GCS bucket client @@ -17,12 +16,5 @@ func NewBucketClient(ctx context.Context, cfg Config, hedgedRoundTripper func(rt ServiceAccount: cfg.ServiceAccount.Value, } - // Thanos currently doesn't support passing the config as is, but expects a YAML, - // so we're going to serialize it. - serialized, err := yaml.Marshal(bucketConfig) - if err != nil { - return nil, err - } - - return gcs.NewBucket(ctx, logger, serialized, name, hedgedRoundTripper) + return gcs.NewBucketWithConfig(ctx, logger, bucketConfig, name, hedgedRoundTripper) } diff --git a/pkg/storage/bucket/swift/bucket_client.go b/pkg/storage/bucket/swift/bucket_client.go index 2e4f8e818a..cd76cabfb6 100644 --- a/pkg/storage/bucket/swift/bucket_client.go +++ b/pkg/storage/bucket/swift/bucket_client.go @@ -7,7 +7,6 @@ import ( "github.com/prometheus/common/model" "github.com/thanos-io/objstore" "github.com/thanos-io/objstore/providers/swift" - yaml "gopkg.in/yaml.v2" ) // NewBucketClient creates a new Swift bucket client @@ -40,12 +39,5 @@ func NewBucketClient(cfg Config, hedgedRoundTripper func(rt http.RoundTripper) h UseDynamicLargeObjects: false, } - // Thanos currently doesn't support passing the config as is, but expects a YAML, - // so we're going to serialize it. - serialized, err := yaml.Marshal(bucketConfig) - if err != nil { - return nil, err - } - - return swift.NewContainer(logger, serialized, hedgedRoundTripper) + return swift.NewContainerFromConfig(logger, &bucketConfig, false, hedgedRoundTripper) }