Appmanager: implement functional search bar
reworked handlers for different app types
Change-Id: I82d3c856aa5c583dcdcf83ed6fbaf440bc4c8f87
diff --git a/core/installer/app_repository.go b/core/installer/app_repository.go
index 1befd7c..381a84f 100644
--- a/core/installer/app_repository.go
+++ b/core/installer/app_repository.go
@@ -9,6 +9,7 @@
"io"
"log"
"net/http"
+ "strings"
"github.com/go-git/go-billy/v5"
"sigs.k8s.io/yaml"
@@ -71,6 +72,7 @@
type AppRepository interface {
GetAll() ([]App, error)
Find(name string) (App, error)
+ Filter(query string) ([]App, error)
}
type InMemoryAppRepository struct {
@@ -104,6 +106,19 @@
)
}
+func (r InMemoryAppRepository) Filter(query string) ([]App, error) {
+ var filteredApps []App
+ if query == "" {
+ return r.GetAll()
+ }
+ for _, a := range r.apps {
+ if strings.Contains(strings.ToLower(a.Name()), strings.ToLower(query)) {
+ filteredApps = append(filteredApps, a)
+ }
+ }
+ return filteredApps, nil
+}
+
func CreateStoreApps() []App {
return CreateEnvApps(storeEnvAppConfigs)
}