aboutsummaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
diff options
context:
space:
mode:
authorEric Multanen <eric.w.multanen@intel.com>2020-06-23 12:23:30 -0700
committerRitu Sood <Ritu.Sood@intel.com>2020-06-26 19:49:03 +0000
commitd972a4453774410868ba48494a80e84232704fe2 (patch)
tree68897029126c548498b34568302b7317e7ea38bd /src/orchestrator/pkg/module/instantiation_appcontext_helper.go
parent8b5fefd9d4e54c3dab7f626e084359800c155b92 (diff)
Add instruction and rsync call to instantiate
This patch adds app and resource 'order' and 'dependency' instructions to the appcontext, as these are currently expected by rsync. Adds the rsync client and call to rsync to instantiate the appcontext. Issue-ID: MULTICLOUD-1064 Signed-off-by: Eric Multanen <eric.w.multanen@intel.com> Change-Id: Iae0da9de4a0ae82bd3ab7ccc72da4abf8b7f2295
Diffstat (limited to 'src/orchestrator/pkg/module/instantiation_appcontext_helper.go')
-rw-r--r--src/orchestrator/pkg/module/instantiation_appcontext_helper.go34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
index 1734a0c8..43ddd6df 100644
--- a/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
+++ b/src/orchestrator/pkg/module/instantiation_appcontext_helper.go
@@ -22,19 +22,21 @@ It contains methods for creating appContext, saving cluster and resource details
*/
import (
+ "encoding/json"
+ "io/ioutil"
+
"github.com/onap/multicloud-k8s/src/orchestrator/pkg/appcontext"
gpic "github.com/onap/multicloud-k8s/src/orchestrator/pkg/gpic"
log "github.com/onap/multicloud-k8s/src/orchestrator/pkg/infra/logutils"
"github.com/onap/multicloud-k8s/src/orchestrator/utils"
"github.com/onap/multicloud-k8s/src/orchestrator/utils/helm"
pkgerrors "github.com/pkg/errors"
- "io/ioutil"
)
// resource consists of name of reource
type resource struct {
name string
- filecontent []byte
+ filecontent string
}
type contextForCompositeApp struct {
@@ -81,17 +83,27 @@ func getResources(st []helm.KubernetesResourceTemplate) ([]resource, error) {
}
n := yamlStruct.Metadata.Name + SEPARATOR + yamlStruct.Kind
- resources = append(resources, resource{name: n, filecontent: yamlFile})
+ resources = append(resources, resource{name: n, filecontent: string(yamlFile)})
log.Info(":: Added resource into resource-order ::", log.Fields{"ResourceName": n})
}
return resources, nil
}
-func addResourcesToCluster(ct appcontext.AppContext, ch interface{}, resources []resource, resourceOrder []string) error {
+func addResourcesToCluster(ct appcontext.AppContext, ch interface{}, resources []resource) error {
+
+ var resOrderInstr struct {
+ Resorder []string `json:"resorder"`
+ }
+
+ var resDepInstr struct {
+ Resdep map[string]string `json:"resdependency"`
+ }
+ resdep := make(map[string]string)
for _, resource := range resources {
- resourceOrder = append(resourceOrder, resource.name)
+ resOrderInstr.Resorder = append(resOrderInstr.Resorder, resource.name)
+ resdep[resource.name] = "go"
_, err := ct.AddResource(ch, resource.name, resource.filecontent)
if err != nil {
cleanuperr := ct.DeleteCompositeApp()
@@ -100,7 +112,11 @@ func addResourcesToCluster(ct appcontext.AppContext, ch interface{}, resources [
}
return pkgerrors.Wrapf(err, "Error adding resource ::%s to AppContext", resource.name)
}
- _, err = ct.AddInstruction(ch, "resource", "order", resourceOrder)
+ jresOrderInstr, _ := json.Marshal(resOrderInstr)
+ resDepInstr.Resdep = resdep
+ jresDepInstr, _ := json.Marshal(resDepInstr)
+ _, err = ct.AddInstruction(ch, "resource", "order", string(jresOrderInstr))
+ _, err = ct.AddInstruction(ch, "resource", "dependency", string(jresDepInstr))
if err != nil {
cleanuperr := ct.DeleteCompositeApp()
if cleanuperr != nil {
@@ -120,7 +136,6 @@ func addClustersToAppContext(l gpic.ClusterList, ct appcontext.AppContext, appHa
for _, c := range mc {
p := c.ProviderName
n := c.ClusterName
- var resourceOrder []string
clusterhandle, err := ct.AddCluster(appHandle, p+SEPARATOR+n)
if err != nil {
cleanuperr := ct.DeleteCompositeApp()
@@ -130,7 +145,7 @@ func addClustersToAppContext(l gpic.ClusterList, ct appcontext.AppContext, appHa
return pkgerrors.Wrapf(err, "Error adding Cluster(provider::%s and name::%s) to AppContext", p, n)
}
- err = addResourcesToCluster(ct, clusterhandle, resources, resourceOrder)
+ err = addResourcesToCluster(ct, clusterhandle, resources)
if err != nil {
return pkgerrors.Wrapf(err, "Error adding Resources to Cluster(provider::%s and name::%s) to AppContext", p, n)
}
@@ -144,7 +159,6 @@ func addClustersToAppContext(l gpic.ClusterList, ct appcontext.AppContext, appHa
p := eachCluster.ProviderName
n := eachCluster.ClusterName
- var resourceOrder []string
clusterhandle, err := ct.AddCluster(appHandle, p+SEPARATOR+n)
if err != nil {
@@ -164,7 +178,7 @@ func addClustersToAppContext(l gpic.ClusterList, ct appcontext.AppContext, appHa
return pkgerrors.Wrapf(err, "Error adding Cluster(provider::%s and name::%s) to AppContext", p, n)
}
- err = addResourcesToCluster(ct, clusterhandle, resources, resourceOrder)
+ err = addResourcesToCluster(ct, clusterhandle, resources)
if err != nil {
return pkgerrors.Wrapf(err, "Error adding Resources to Cluster(provider::%s, name::%s and groupName:: %s) to AppContext", p, n, gn)
}