From 3b848c7b4b6a4a49658bd9275a0baa6a08effe2a Mon Sep 17 00:00:00 2001 From: Srivahni Chivukula Date: Thu, 12 Mar 2020 15:50:42 -0700 Subject: Added getAllApps functionality in App api Issue-ID: MULTICLOUD-994 Signed-off-by: Srivahni Chivukula Change-Id: I459504c45b9bedea0e6bc15ca57e7876d5f59d28 --- src/orchestrator/pkg/module/app.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/orchestrator/pkg/module') diff --git a/src/orchestrator/pkg/module/app.go b/src/orchestrator/pkg/module/app.go index c25a1b51..1e1a5974 100644 --- a/src/orchestrator/pkg/module/app.go +++ b/src/orchestrator/pkg/module/app.go @@ -65,6 +65,7 @@ type AppManager interface { CreateApp(a App, ac AppContent, p string, cN string, cV string) (App, error) GetApp(name string, p string, cN string, cV string) (App, error) GetAppContent(name string, p string, cN string, cV string) (AppContent, error) + GetApps(p string, cN string, cV string) ([]App, error) DeleteApp(name string, p string, cN string, cV string) error } @@ -183,6 +184,34 @@ func (v *AppClient) GetAppContent(name string, p string, cN string, cV string) ( return AppContent{}, pkgerrors.New("Error getting app content") } +// GetApps returns all Apps for given composite App +func (v *AppClient) GetApps(project, compositeApp, compositeAppVersion string) ([]App, error) { + + key := AppKey{ + App: "", + Project: project, + CompositeApp: compositeApp, + CompositeAppVersion: compositeAppVersion, + } + + var resp []App + values, err := db.DBconn.Find(v.storeName, key, v.tagMeta) + if err != nil { + return []App{}, pkgerrors.Wrap(err, "Get Apps") + } + + for _, value := range values { + a := App{} + err = db.DBconn.Unmarshal(value, &a) + if err != nil { + return []App{}, pkgerrors.Wrap(err, "Unmarshaling Value") + } + resp = append(resp, a) + } + + return resp, nil +} + // DeleteApp deletes the App from database func (v *AppClient) DeleteApp(name string, p string, cN string, cV string) error { -- cgit 1.2.3-korg