aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg
diff options
context:
space:
mode:
authorRajamohan Raj <rajamohan.raj@intel.com>2020-07-17 02:11:13 +0000
committerRajamohan Raj <rajamohan.raj@intel.com>2020-07-17 02:17:49 +0000
commit09ade2b51d5e3d4da5921115a993bec97a905e1b (patch)
tree68879bcda8b583c2afdf6831c09af8a40a6c5a41 /src/orchestrator/pkg
parent46feb5b7bb5ed0348261637be34bd368155b55b7 (diff)
Add API to query all composite apps under a project
In this patch implemented a new route to query all compApps under a project. Issue-ID: MULTICLOUD-1127 Signed-off-by: Rajamohan Raj <rajamohan.raj@intel.com> Change-Id: I5d5d4861539edd2ca0eccff16d94b75439e14db7
Diffstat (limited to 'src/orchestrator/pkg')
-rw-r--r--src/orchestrator/pkg/module/compositeapp.go33
-rw-r--r--src/orchestrator/pkg/module/instantiation_appcontext_helper.go2
2 files changed, 34 insertions, 1 deletions
diff --git a/src/orchestrator/pkg/module/compositeapp.go b/src/orchestrator/pkg/module/compositeapp.go
index 70502367..5bf7ddec 100644
--- a/src/orchestrator/pkg/module/compositeapp.go
+++ b/src/orchestrator/pkg/module/compositeapp.go
@@ -64,6 +64,7 @@ func (cK CompositeAppKey) String() string {
type CompositeAppManager interface {
CreateCompositeApp(c CompositeApp, p string) (CompositeApp, error)
GetCompositeApp(name string, version string, p string) (CompositeApp, error)
+ GetAllCompositeApps(p string) ([]CompositeApp, error)
DeleteCompositeApp(name string, version string, p string) error
}
@@ -140,6 +141,38 @@ func (v *CompositeAppClient) GetCompositeApp(name string, version string, p stri
return CompositeApp{}, pkgerrors.New("Error getting composite application")
}
+// GetAllCompositeApps returns all the compositeApp for a given project
+func (v *CompositeAppClient) GetAllCompositeApps(p string) ([]CompositeApp, error) {
+
+ _, err := NewProjectClient().GetProject(p)
+ if err != nil {
+ return []CompositeApp{}, pkgerrors.New("Unable to find the project")
+ }
+
+ key := CompositeAppKey{
+ CompositeAppName: "",
+ Version: "",
+ Project: p,
+ }
+
+ var caList []CompositeApp
+ values, err := db.DBconn.Find(v.storeName, key, v.tagMeta)
+ if err != nil {
+ return []CompositeApp{}, pkgerrors.Wrap(err, "Getting CompositeApps")
+ }
+
+ for _, value := range values {
+ ca := CompositeApp{}
+ err = db.DBconn.Unmarshal(value, &ca)
+ if err != nil {
+ return []CompositeApp{}, pkgerrors.Wrap(err, "Unmarshaling CompositeApp")
+ }
+ caList = append(caList, ca)
+ }
+
+ return caList, nil
+}
+
// DeleteCompositeApp deletes the CompositeApp from database
func (v *CompositeAppClient) DeleteCompositeApp(name string, version string, p string) error {
diff --git a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
index 1cb3f23d..a8c6eda7 100644
--- a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
+++ b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
@@ -89,7 +89,7 @@ func getResources(st []helm.KubernetesResourceTemplate) ([]resource, error) {
// This might happen when the rendered file just has some comments inside, no real k8s object.
if n == SEPARATOR {
log.Info(":: Ignoring, Unable to render the template ::", log.Fields{"YAML PATH": t.FilePath})
- continue;
+ continue
}
resources = append(resources, resource{name: n, filecontent: string(yamlFile)})