Skip to content

Commit

Permalink
refactor bucket client to pass config directly
Browse files Browse the repository at this point in the history
Signed-off-by: SungJin1212 <[email protected]>
  • Loading branch information
SungJin1212 committed Dec 19, 2024
1 parent cfe7ac3 commit 5ca0684
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 27 deletions.
10 changes: 1 addition & 9 deletions pkg/storage/bucket/azure/bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
}
10 changes: 1 addition & 9 deletions pkg/storage/bucket/gcs/bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
10 changes: 1 addition & 9 deletions pkg/storage/bucket/swift/bucket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

0 comments on commit 5ca0684

Please sign in to comment.