Skip to content

Commit

Permalink
Remove duplicated transformation of string->[]byte
Browse files Browse the repository at this point in the history
Signed-off-by: jademcosta <jade.costa@nubank.com.br>
  • Loading branch information
jademcosta committed May 17, 2022
1 parent 6303342 commit 1481f24
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pkg/objstore/client/factory.go
Expand Up @@ -82,8 +82,9 @@ func NewBucket(logger log.Logger, confContentYaml []byte, reg prometheus.Registe
return nil, errors.Wrap(err, fmt.Sprintf("create %s client", bucketConf.Type))
}

prefix := PrefixFromConfig(string(confContentYaml))
prefix := prefixFromConfig(confContentYaml)
var prefixedBucket objstore.Bucket

if validPrefix(prefix) {
prefixedBucket = objstore.NewPrefixedBucket(bucket, prefix)
level.Debug(logger).Log("msg", "using prefix on bucket access", "prefix", prefix)
Expand All @@ -99,9 +100,10 @@ func validPrefix(prefix string) bool {
return len(prefix) > 0
}

func PrefixFromConfig(confYaml string) string {
func prefixFromConfig(confYaml []byte) string {
bucketConf := &BucketConfig{}
err := yaml.UnmarshalStrict([]byte(confYaml), &bucketConf)
err := yaml.UnmarshalStrict(confYaml, &bucketConf)

if err != nil {
return ""
}
Expand Down

0 comments on commit 1481f24

Please sign in to comment.