corso/src/internal/common/buckets.go
Georgi Matev 0c921e8b40
Normalize repo suffix paths (#1153)
## Description

Repo `--prefix` values should be normalized with a trailing `/`

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [ ] 🌻 Feature
- [x] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

* Fixes #1152  

## Test Plan

<!-- How will this be tested prior to merging.-->
- [] 💪 Manual
- [x]  Unit test
- [ ] 💚 E2E
2022-10-13 02:11:13 +00:00

26 lines
642 B
Go

package common
import "strings"
// NormalizeBuckets ensures that bucket names are cleaned and
// standardized according to the downstream needs of minio.
//
// Any url prefixing to location the bucket (ex: s3://bckt)
// will be removed, leaving only the bucket name (bckt).
// Corso should only utilize or store the normalized name.
func NormalizeBucket(b string) string {
return strings.TrimPrefix(b, "s3://")
}
// NormalizePrefix ensures that a bucket prefix is always treated as
// object store folder prefix.
func NormalizePrefix(p string) string {
tp := strings.TrimRight(p, "/")
if len(tp) > 0 {
tp = tp + "/"
}
return tp
}