Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add constructor for a client from a BucketConfig object #163

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re
- [#150](https://github.com/thanos-io/objstore/pull/150) Add support for roundtripper wrapper.
- [#63](https://github.com/thanos-io/objstore/pull/63) Implement a `IterWithAttributes` method on the bucket client.
- [#155](https://github.com/thanos-io/objstore/pull/155) Add a `Provider` method on `objstore.Client`.
- [#163](https://github.com/thanos-io/objstore/pull/145) Add a `NewBucketFromConfig` constructor method for creating a client from an existing `BucketConfig` object.


### Changed
Expand Down
5 changes: 5 additions & 0 deletions client/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ func NewBucket(logger log.Logger, confContentYaml []byte, component string, wrap
return nil, errors.Wrap(err, "parsing config YAML file")
}

return NewBucketFromConfig(logger, bucketConf, component, wrapRoundtripper)
}

// NewBucketFromConfig creates an objstore.Bucket from an existing BucketConfig object.
func NewBucketFromConfig(logger log.Logger, bucketConf *BucketConfig, component string, wrapRoundtripper func(http.RoundTripper) http.RoundTripper) (objstore.Bucket, error) {
config, err := yaml.Marshal(bucketConf.Config)
if err != nil {
return nil, errors.Wrap(err, "marshal content of bucket configuration")
Expand Down
Loading