Skip to content

Commit 3b326c4

Browse files
authored
refactor bucket client to pass config directly (#6446)
Signed-off-by: SungJin1212 <[email protected]>
1 parent 4b8203c commit 3b326c4

File tree

3 files changed

+3
-27
lines changed

3 files changed

+3
-27
lines changed

pkg/storage/bucket/azure/bucket_client.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"github.com/thanos-io/objstore"
99
"github.com/thanos-io/objstore/exthttp"
1010
"github.com/thanos-io/objstore/providers/azure"
11-
yaml "gopkg.in/yaml.v2"
1211
)
1312

1413
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
3231
},
3332
}
3433

35-
// Thanos currently doesn't support passing the config as is, but expects a YAML,
36-
// so we're going to serialize it.
37-
serialized, err := yaml.Marshal(bucketConfig)
38-
if err != nil {
39-
return nil, err
40-
}
41-
42-
return azure.NewBucket(logger, serialized, name, hedgedRoundTripper)
34+
return azure.NewBucketWithConfig(logger, bucketConfig, name, hedgedRoundTripper)
4335
}

pkg/storage/bucket/gcs/bucket_client.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/go-kit/log"
88
"github.com/thanos-io/objstore"
99
"github.com/thanos-io/objstore/providers/gcs"
10-
yaml "gopkg.in/yaml.v2"
1110
)
1211

1312
// NewBucketClient creates a new GCS bucket client
@@ -17,12 +16,5 @@ func NewBucketClient(ctx context.Context, cfg Config, hedgedRoundTripper func(rt
1716
ServiceAccount: cfg.ServiceAccount.Value,
1817
}
1918

20-
// Thanos currently doesn't support passing the config as is, but expects a YAML,
21-
// so we're going to serialize it.
22-
serialized, err := yaml.Marshal(bucketConfig)
23-
if err != nil {
24-
return nil, err
25-
}
26-
27-
return gcs.NewBucket(ctx, logger, serialized, name, hedgedRoundTripper)
19+
return gcs.NewBucketWithConfig(ctx, logger, bucketConfig, name, hedgedRoundTripper)
2820
}

pkg/storage/bucket/swift/bucket_client.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"github.com/prometheus/common/model"
88
"github.com/thanos-io/objstore"
99
"github.com/thanos-io/objstore/providers/swift"
10-
yaml "gopkg.in/yaml.v2"
1110
)
1211

1312
// NewBucketClient creates a new Swift bucket client
@@ -40,12 +39,5 @@ func NewBucketClient(cfg Config, hedgedRoundTripper func(rt http.RoundTripper) h
4039
UseDynamicLargeObjects: false,
4140
}
4241

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, hedgedRoundTripper)
42+
return swift.NewContainerFromConfig(logger, &bucketConfig, false, hedgedRoundTripper)
5143
}

0 commit comments

Comments
 (0)