Skip to content

Commit

Permalink
refactor: move prefix to config root level
Browse files Browse the repository at this point in the history
Signed-off-by: Maria Eduarda Duarte <dudammduarte@yahoo.com.br>
  • Loading branch information
dudaduarte committed May 31, 2022
1 parent 8cf041e commit 173321d
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions pkg/objstore/client/factory.go
Expand Up @@ -41,6 +41,7 @@ const (
type BucketConfig struct {
Type ObjProvider `yaml:"type"`
Config interface{} `yaml:"config"`
Prefix string `yaml:"prefix" default:""`
}

// NewBucket initializes and returns new object storage clients.
Expand Down Expand Up @@ -82,16 +83,5 @@ func NewBucket(logger log.Logger, confContentYaml []byte, reg prometheus.Registe
return nil, errors.Wrap(err, fmt.Sprintf("create %s client", bucketConf.Type))
}

prefix := prefixFromConfig(bucketConf)

return objstore.NewTracingBucket(objstore.BucketWithMetrics(bucket.Name(), objstore.NewPrefixedBucket(bucket, prefix), reg)), nil
}

func prefixFromConfig(bucketConf *BucketConfig) string {
prefix, ok := bucketConf.Config.(map[interface{}]interface{})["prefix"]
if !ok {
return ""
}

return prefix.(string)
return objstore.NewTracingBucket(objstore.BucketWithMetrics(bucket.Name(), objstore.NewPrefixedBucket(bucket, bucketConf.Prefix), reg)), nil
}

0 comments on commit 173321d

Please sign in to comment.