Skip to content

Commit

Permalink
Merge pull request #163 from fpetkovski/bucket-from-config
Browse files Browse the repository at this point in the history
Add constructor for a client from a BucketConfig object
  • Loading branch information
fpetkovski authored Jan 29, 2025
2 parents 4b72edf + 3f90dac commit ec72e5a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
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

0 comments on commit ec72e5a

Please sign in to comment.