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:
Nicol
2023-04-18 21:07:47 +03:00
committed by GitHub
parent e63faa8898
commit 0586c6227e
25 changed files with 561 additions and 595 deletions
+2 -2
View File
@@ -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 {
+13
View File
@@ -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")
})
}