mirror of
https://github.com/project-zot/zot.git
synced 2026-06-16 04:17:55 +08:00
refactor: remove pkg/extensions/search/common and move the code to the appropriate packages (#1358)
Signed-off-by: Nicol Draghici <idraghic@cisco.com>
This commit is contained in:
@@ -16,7 +16,7 @@ type BlobUpload struct {
|
||||
ID string
|
||||
}
|
||||
|
||||
func getRoutePrefix(name string) string {
|
||||
func GetRoutePrefix(name string) string {
|
||||
names := strings.SplitN(name, "/", 2) //nolint:gomnd
|
||||
|
||||
if len(names) != 2 { //nolint:gomnd
|
||||
@@ -32,7 +32,7 @@ func getRoutePrefix(name string) string {
|
||||
func (sc StoreController) GetImageStore(name string) ImageStore {
|
||||
if sc.SubStore != nil {
|
||||
// SubStore is being provided, now we need to find equivalent image store and this will be found by splitting name
|
||||
prefixName := getRoutePrefix(name)
|
||||
prefixName := GetRoutePrefix(name)
|
||||
|
||||
imgStore, ok := sc.SubStore[prefixName]
|
||||
if !ok {
|
||||
|
||||
@@ -902,3 +902,16 @@ func TestStorageHandler(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestRoutePrefix(t *testing.T) {
|
||||
Convey("Test route prefix", t, func() {
|
||||
routePrefix := storage.GetRoutePrefix("test:latest")
|
||||
So(routePrefix, ShouldEqual, "/")
|
||||
|
||||
routePrefix = storage.GetRoutePrefix("a/test:latest")
|
||||
So(routePrefix, ShouldEqual, "/a")
|
||||
|
||||
routePrefix = storage.GetRoutePrefix("a/b/test:latest")
|
||||
So(routePrefix, ShouldEqual, "/a")
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user