From a6603eb210c4135f70862e4d6912399cf1c260d8 Mon Sep 17 00:00:00 2001 From: Yoshiki Fujikane Date: Thu, 26 Dec 2024 17:15:38 +0900 Subject: [PATCH] Implement ListByPluginName Signed-off-by: Yoshiki Fujikane --- .../apistore/applicationstore/store.go | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkg/app/pipedv1/apistore/applicationstore/store.go b/pkg/app/pipedv1/apistore/applicationstore/store.go index d9c9ccf54d..56436cdef4 100644 --- a/pkg/app/pipedv1/apistore/applicationstore/store.go +++ b/pkg/app/pipedv1/apistore/applicationstore/store.go @@ -36,6 +36,8 @@ type Lister interface { ListByPlatformProvider(name string) []*model.Application // Get retrieves a specifiec deployment for the given id. Get(id string) (*model.Application, bool) + // ListByPluginName lists all applications for a given plugin name. + ListByPluginName(name string) []*model.Application } type apiClient interface { @@ -159,6 +161,19 @@ func (s *store) Get(id string) (*model.Application, bool) { // ListByPluginName lists all applications for a given plugin name. func (s *store) ListByPluginName(name string) []*model.Application { - // TODO: implement it - return nil + apps := s.applicationList.Load() + if apps == nil { + return nil + } + + out := make([]*model.Application, 0) + list := apps.([]*model.Application) + + for _, app := range list { + if app.Plugin == name { + out = append(out, app) + } + } + + return out }