summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator/pkg')
-rw-r--r--src/orchestrator/pkg/module/app_intent.go49
-rw-r--r--src/orchestrator/pkg/module/app_intent_test.go43
-rw-r--r--src/orchestrator/pkg/module/deployment_intent_groups.go1
-rw-r--r--src/orchestrator/pkg/module/deployment_intent_groups_test.go8
-rw-r--r--src/orchestrator/pkg/module/generic_placement_intent.go44
-rw-r--r--src/orchestrator/pkg/module/generic_placement_intent_test.go56
-rw-r--r--src/orchestrator/pkg/module/instantiation.go2
7 files changed, 151 insertions, 52 deletions
diff --git a/src/orchestrator/pkg/module/app_intent.go b/src/orchestrator/pkg/module/app_intent.go
index 9da252e5..f2f4e070 100644
--- a/src/orchestrator/pkg/module/app_intent.go
+++ b/src/orchestrator/pkg/module/app_intent.go
@@ -53,11 +53,11 @@ type SpecData struct {
// AppIntentManager is an interface which exposes the
// AppIntentManager functionalities
type AppIntentManager interface {
- CreateAppIntent(a AppIntent, p string, ca string, v string, i string) (AppIntent, error)
- GetAppIntent(ai string, p string, ca string, v string, i string) (AppIntent, error)
- GetAllIntentsByApp(aN, p, ca, v, i string) (SpecData, error)
- GetAllAppIntents(p, ca, v, i string) (ApplicationsAndClusterInfo, error)
- DeleteAppIntent(ai string, p string, ca string, v string, i string) error
+ CreateAppIntent(a AppIntent, p string, ca string, v string, i string, digName string) (AppIntent, error)
+ GetAppIntent(ai string, p string, ca string, v string, i string, digName string) (AppIntent, error)
+ GetAllIntentsByApp(aN, p, ca, v, i, digName string) (SpecData, error)
+ GetAllAppIntents(p, ca, v, i, digName string) (ApplicationsAndClusterInfo, error)
+ DeleteAppIntent(ai string, p string, ca string, v string, i string, digName string) error
}
//AppIntentQueryKey required for query
@@ -72,6 +72,7 @@ type AppIntentKey struct {
CompositeApp string `json:"compositeapp"`
Version string `json:"compositeappversion"`
Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroupname"`
}
// AppIntentFindByAppKey required for query
@@ -80,6 +81,7 @@ type AppIntentFindByAppKey struct {
CompositeApp string `json:"compositeapp"`
CompositeAppVersion string `json:"compositeappversion"`
Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroupname"`
AppName string `json:"app-name"`
}
@@ -121,11 +123,11 @@ func NewAppIntentClient() *AppIntentClient {
}
// CreateAppIntent creates an entry for AppIntent in the db.
-// Other input parameters for it - projectName, compositeAppName, version, intentName.
-func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v string, i string) (AppIntent, error) {
+// Other input parameters for it - projectName, compositeAppName, version, intentName and deploymentIntentGroupName.
+func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v string, i string, digName string) (AppIntent, error) {
//Check for the AppIntent already exists here.
- res, err := c.GetAppIntent(a.MetaData.Name, p, ca, v, i)
+ res, err := c.GetAppIntent(a.MetaData.Name, p, ca, v, i, digName)
if !reflect.DeepEqual(res, AppIntent{}) {
return AppIntent{}, pkgerrors.New("AppIntent already exists")
}
@@ -143,17 +145,24 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
}
// check if Intent exists
- _, err = NewGenericPlacementIntentClient().GetGenericPlacementIntent(i, p, ca, v)
+ _, err = NewGenericPlacementIntentClient().GetGenericPlacementIntent(i, p, ca, v, digName)
if err != nil {
return AppIntent{}, pkgerrors.New("Unable to find the intent")
}
+ // check if the deploymentIntentGrpName exists
+ _, err = NewDeploymentIntentGroupClient().GetDeploymentIntentGroup(digName,p, ca, v)
+ if err != nil {
+ return AppIntent{}, pkgerrors.New("Unable to find the deployment-intent-group-name")
+ }
+
akey := AppIntentKey{
Name: a.MetaData.Name,
Project: p,
CompositeApp: ca,
Version: v,
Intent: i,
+ DeploymentIntentGroupName: digName,
}
qkey := AppIntentQueryKey{
@@ -164,12 +173,12 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
if err != nil {
return AppIntent{}, pkgerrors.Wrap(err, "Create DB entry error")
}
-
+
return a, nil
}
-// GetAppIntent shall take arguments - name of the app intent, name of the project, name of the composite app, version of the composite app and intent name. It shall return the AppIntent
-func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string, i string) (AppIntent, error) {
+// GetAppIntent shall take arguments - name of the app intent, name of the project, name of the composite app, version of the composite app,intent name and deploymentIntentGroupName. It shall return the AppIntent
+func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string, i string, digName string) (AppIntent, error) {
k := AppIntentKey{
Name: ai,
@@ -177,6 +186,7 @@ func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string,
CompositeApp: ca,
Version: v,
Intent: i,
+ DeploymentIntentGroupName: digName,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
@@ -197,16 +207,17 @@ func (c *AppIntentClient) GetAppIntent(ai string, p string, ca string, v string,
}
/*
-GetAllIntentsByApp takes in parameters AppName, CompositeAppName, CompositeNameVersion
-and GenericPlacementIntentName. Returns SpecData which contains
+GetAllIntentsByApp queries intent by AppName, it takes in parameters AppName, CompositeAppName, CompositeNameVersion,
+GenericPlacementIntentName & DeploymentIntentGroupName. Returns SpecData which contains
all the intents for the app.
*/
-func (c *AppIntentClient) GetAllIntentsByApp(aN, p, ca, v, i string) (SpecData, error) {
+func (c *AppIntentClient) GetAllIntentsByApp(aN, p, ca, v, i, digName string) (SpecData, error) {
k := AppIntentFindByAppKey{
Project: p,
CompositeApp: ca,
CompositeAppVersion: v,
Intent: i,
+ DeploymentIntentGroupName: digName,
AppName: aN,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
@@ -224,15 +235,16 @@ func (c *AppIntentClient) GetAllIntentsByApp(aN, p, ca, v, i string) (SpecData,
/*
GetAllAppIntents takes in paramaters ProjectName, CompositeAppName, CompositeNameVersion
-and GenericPlacementIntentName. Returns the ApplicationsAndClusterInfo Object - an array of AppClusterInfo
+and GenericPlacementIntentName,DeploymentIntentGroupName. Returns the ApplicationsAndClusterInfo Object - an array of AppClusterInfo
*/
-func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i string) (ApplicationsAndClusterInfo, error) {
+func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i, digName string) (ApplicationsAndClusterInfo, error) {
k := AppIntentKey{
Name: "",
Project: p,
CompositeApp: ca,
Version: v,
Intent: i,
+ DeploymentIntentGroupName: digName,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
if err != nil {
@@ -262,13 +274,14 @@ func (c *AppIntentClient) GetAllAppIntents(p, ca, v, i string) (ApplicationsAndC
}
// DeleteAppIntent delete an AppIntent
-func (c *AppIntentClient) DeleteAppIntent(ai string, p string, ca string, v string, i string) error {
+func (c *AppIntentClient) DeleteAppIntent(ai string, p string, ca string, v string, i string, digName string) error {
k := AppIntentKey{
Name: ai,
Project: p,
CompositeApp: ca,
Version: v,
Intent: i,
+ DeploymentIntentGroupName: digName,
}
err := db.DBconn.Remove(c.storeName, k)
diff --git a/src/orchestrator/pkg/module/app_intent_test.go b/src/orchestrator/pkg/module/app_intent_test.go
index 089f09ff..a2e295ea 100644
--- a/src/orchestrator/pkg/module/app_intent_test.go
+++ b/src/orchestrator/pkg/module/app_intent_test.go
@@ -33,6 +33,7 @@ func TestCreateAppIntent(t *testing.T) {
inputCompositeApp string
inputCompositeAppVersion string
inputGenericPlacementIntent string
+ inputDeploymentIntentGrpName string
expectedError string
mockdb *db.MockDB
expected AppIntent
@@ -81,6 +82,7 @@ func TestCreateAppIntent(t *testing.T) {
inputCompositeApp: "testCompositeApp",
inputCompositeAppVersion: "testCompositeAppVersion",
inputGenericPlacementIntent: "testIntent",
+ inputDeploymentIntentGrpName: "testDeploymentIntentGroup",
expected: AppIntent{
MetaData: MetaData{
Name: "testAppIntent",
@@ -142,6 +144,7 @@ func TestCreateAppIntent(t *testing.T) {
Project: "testProject",
CompositeApp: "testCompositeApp",
Version: "testCompositeAppVersion",
+ DigName: "testDeploymentIntentGroup",
}.String(): {
"genericplacementintentmetadata": []byte(
"{\"metadata\":{\"Name\":\"testIntent\"," +
@@ -150,6 +153,39 @@ func TestCreateAppIntent(t *testing.T) {
"\"UserData2\": \"userData2\"}," +
"\"spec\":{\"Logical-Cloud\": \"logicalCloud1\"}}"),
},
+ DeploymentIntentGroupKey{
+ Name: "testDeploymentIntentGroup",
+ Project: "testProject",
+ CompositeApp: "testCompositeApp",
+ Version: "testCompositeAppVersion",
+ }.String(): {
+ "deploymentintentgroupmetadata": []byte(
+ "{\"metadata\":{\"name\":\"testDeploymentIntentGroup\"," +
+ "\"description\":\"DescriptionTestDeploymentIntentGroup\"," +
+ "\"userData1\": \"userData1\"," +
+ "\"userData2\": \"userData2\"}," +
+ "\"spec\":{\"profile\": \"Testprofile\"," +
+ "\"version\": \"version of deployment\"," +
+ "\"override-values\":[" +
+ "{" +
+ "\"app-name\": \"TestAppName\"," +
+ "\"values\": " +
+ "{" +
+ "\"imageRepository\":\"registry.hub.docker.com\"" +
+ "}" +
+ "}," +
+ "{" +
+ "\"app-name\": \"TestAppName\"," +
+ "\"values\": " +
+ "{" +
+ "\"imageRepository\":\"registry.hub.docker.com\"" +
+ "}" +
+ "}" +
+ "]," +
+ "\"logical-cloud\": \"cloud1\"" +
+ "}"+
+ "}"),
+ },
},
},
},
@@ -158,7 +194,7 @@ func TestCreateAppIntent(t *testing.T) {
t.Run(testCase.label, func(t *testing.T) {
db.DBconn = testCase.mockdb
appIntentCli := NewAppIntentClient()
- got, err := appIntentCli.CreateAppIntent(testCase.inputAppIntent, testCase.inputProject, testCase.inputCompositeApp, testCase.inputCompositeAppVersion, testCase.inputGenericPlacementIntent)
+ got, err := appIntentCli.CreateAppIntent(testCase.inputAppIntent, testCase.inputProject, testCase.inputCompositeApp, testCase.inputCompositeAppVersion, testCase.inputGenericPlacementIntent, testCase.inputDeploymentIntentGrpName)
if err != nil {
if testCase.expectedError == "" {
t.Fatalf("CreateAppIntent returned an unexpected error %s, ", err)
@@ -186,6 +222,7 @@ func TestGetAppIntent(t *testing.T) {
compositeAppName string
compositeAppVersion string
genericPlacementIntent string
+ deploymentIntentgrpName string
}{
{
label: "Get Intent",
@@ -194,6 +231,7 @@ func TestGetAppIntent(t *testing.T) {
compositeAppName: "testCompositeApp",
compositeAppVersion: "testCompositeAppVersion",
genericPlacementIntent: "testIntent",
+ deploymentIntentgrpName: "testDeploymentIntentGroup",
expected: AppIntent{
MetaData: MetaData{
Name: "testAppIntent",
@@ -234,6 +272,7 @@ func TestGetAppIntent(t *testing.T) {
CompositeApp: "testCompositeApp",
Version: "testCompositeAppVersion",
Intent: "testIntent",
+ DeploymentIntentGroupName: "testDeploymentIntentGroup",
}.String(): {
"appintentmetadata": []byte(
"{\"metadata\":{\"Name\":\"testAppIntent\"," +
@@ -270,7 +309,7 @@ func TestGetAppIntent(t *testing.T) {
db.DBconn = testCase.mockdb
appIntentCli := NewAppIntentClient()
got, err := appIntentCli.GetAppIntent(testCase.appIntentName, testCase.projectName, testCase.compositeAppName, testCase.compositeAppVersion,
- testCase.genericPlacementIntent)
+ testCase.genericPlacementIntent, testCase.deploymentIntentgrpName)
if err != nil {
if testCase.expectedError == "" {
t.Fatalf("GetAppIntent returned an unexpected error: %s", err)
diff --git a/src/orchestrator/pkg/module/deployment_intent_groups.go b/src/orchestrator/pkg/module/deployment_intent_groups.go
index dec6391f..f8e434f4 100644
--- a/src/orchestrator/pkg/module/deployment_intent_groups.go
+++ b/src/orchestrator/pkg/module/deployment_intent_groups.go
@@ -47,6 +47,7 @@ type DepSpecData struct {
Profile string `json:"profile"`
Version string `json:"version"`
OverrideValuesObj []OverrideValues `json:"override-values"`
+ LogicalCloud string `json:"logical-cloud"`
}
// OverrideValues has appName and ValuesObj
diff --git a/src/orchestrator/pkg/module/deployment_intent_groups_test.go b/src/orchestrator/pkg/module/deployment_intent_groups_test.go
index 0fdeb4a1..86ae49df 100644
--- a/src/orchestrator/pkg/module/deployment_intent_groups_test.go
+++ b/src/orchestrator/pkg/module/deployment_intent_groups_test.go
@@ -57,6 +57,7 @@ func TestCreateDeploymentIntentGroup(t *testing.T) {
"imageRepository": "registry.hub.docker.com",
}},
},
+ LogicalCloud: "cloud1",
},
},
inputProject: "testProject",
@@ -82,6 +83,7 @@ func TestCreateDeploymentIntentGroup(t *testing.T) {
"imageRepository": "registry.hub.docker.com",
}},
},
+ LogicalCloud: "cloud1",
},
},
expectedError: "",
@@ -167,6 +169,7 @@ func TestGetDeploymentIntentGroup(t *testing.T) {
"imageRepository": "registry.hub.docker.com",
}},
},
+ LogicalCloud: "cloud1",
},
},
expectedError: "",
@@ -200,7 +203,10 @@ func TestGetDeploymentIntentGroup(t *testing.T) {
"\"imageRepository\":\"registry.hub.docker.com\"" +
"}" +
"}" +
- "]}}"),
+ "]," +
+ "\"logical-cloud\": \"cloud1\"" +
+ "}"+
+ "}"),
},
},
},
diff --git a/src/orchestrator/pkg/module/generic_placement_intent.go b/src/orchestrator/pkg/module/generic_placement_intent.go
index fb00a6ab..eb9ed796 100644
--- a/src/orchestrator/pkg/module/generic_placement_intent.go
+++ b/src/orchestrator/pkg/module/generic_placement_intent.go
@@ -26,7 +26,6 @@ import (
// GenericPlacementIntent shall have 2 fields - metadata and spec
type GenericPlacementIntent struct {
MetaData GenIntentMetaData `json:"metadata"`
- Spec GenIntentSpecData `json:"spec"`
}
// GenIntentMetaData has name, description, userdata1, userdata2
@@ -37,21 +36,19 @@ type GenIntentMetaData struct {
UserData2 string `json:"userData2"`
}
-// GenIntentSpecData has logical-cloud-name
-type GenIntentSpecData struct {
- LogicalCloud string `json:"logical-cloud"`
-}
+
+
// GenericPlacementIntentManager is an interface which exposes the GenericPlacementIntentManager functionality
type GenericPlacementIntentManager interface {
CreateGenericPlacementIntent(g GenericPlacementIntent, p string, ca string,
- v string) (GenericPlacementIntent, error)
+ v string, digName string) (GenericPlacementIntent, error)
GetGenericPlacementIntent(intentName string, projectName string,
- compositeAppName string, version string) (GenericPlacementIntent, error)
+ compositeAppName string, version string, digName string) (GenericPlacementIntent, error)
DeleteGenericPlacementIntent(intentName string, projectName string,
- compositeAppName string, version string) error
+ compositeAppName string, version string, digName string) error
- GetAllGenericPlacementIntents(p string, ca string, v string) ([]GenericPlacementIntent, error)
+ GetAllGenericPlacementIntents(p string, ca string, v string, digName string) ([]GenericPlacementIntent, error)
}
// GenericPlacementIntentKey is used as the primary key
@@ -60,6 +57,7 @@ type GenericPlacementIntentKey struct {
Project string `json:"project"`
CompositeApp string `json:"compositeapp"`
Version string `json:"compositeappversion"`
+ DigName string `json:"deploymentintentgroupname"`
}
// We will use json marshalling to convert to string to
@@ -86,12 +84,12 @@ func NewGenericPlacementIntentClient() *GenericPlacementIntentClient {
}
}
-// CreateGenericPlacementIntent creates an entry for GenericPlacementIntent in the database. Other Input parameters for it - projectName, compositeAppName, version
+// CreateGenericPlacementIntent creates an entry for GenericPlacementIntent in the database. Other Input parameters for it - projectName, compositeAppName, version and deploymentIntentGroupName
func (c *GenericPlacementIntentClient) CreateGenericPlacementIntent(g GenericPlacementIntent, p string, ca string,
- v string) (GenericPlacementIntent, error) {
+ v string, digName string) (GenericPlacementIntent, error) {
// check if the genericPlacement already exists.
- res, err := c.GetGenericPlacementIntent(g.MetaData.Name, p, ca, v)
+ res, err := c.GetGenericPlacementIntent(g.MetaData.Name, p, ca, v, digName)
if res != (GenericPlacementIntent{}) {
return GenericPlacementIntent{}, pkgerrors.New("Intent already exists")
}
@@ -108,11 +106,19 @@ func (c *GenericPlacementIntentClient) CreateGenericPlacementIntent(g GenericPla
return GenericPlacementIntent{}, pkgerrors.New("Unable to find the composite-app")
}
+ // check if the deploymentIntentGrpName exists
+ _, err = NewDeploymentIntentGroupClient().GetDeploymentIntentGroup(digName, p, ca, v)
+ if err != nil {
+ return GenericPlacementIntent{}, pkgerrors.New("Unable to find the deployment-intent-group-name")
+ }
+
+
gkey := GenericPlacementIntentKey{
Name: g.MetaData.Name,
Project: p,
CompositeApp: ca,
Version: v,
+ DigName: digName,
}
err = db.DBconn.Insert(c.storeName, gkey, nil, c.tagMetaData, g)
@@ -123,13 +129,14 @@ func (c *GenericPlacementIntentClient) CreateGenericPlacementIntent(g GenericPla
return g, nil
}
-// GetGenericPlacementIntent shall take arguments - name of the intent, name of the project, name of the composite app and version of the composite app. It shall return the genericPlacementIntent if its present.
-func (c *GenericPlacementIntentClient) GetGenericPlacementIntent(i string, p string, ca string, v string) (GenericPlacementIntent, error) {
+// GetGenericPlacementIntent shall take arguments - name of the intent, name of the project, name of the composite app, version of the composite app and deploymentIntentGroupName. It shall return the genericPlacementIntent if its present.
+func (c *GenericPlacementIntentClient) GetGenericPlacementIntent(i string, p string, ca string, v string, digName string) (GenericPlacementIntent, error) {
key := GenericPlacementIntentKey{
Name: i,
Project: p,
CompositeApp: ca,
Version: v,
+ DigName: digName,
}
result, err := db.DBconn.Find(c.storeName, key, c.tagMetaData)
@@ -150,8 +157,8 @@ func (c *GenericPlacementIntentClient) GetGenericPlacementIntent(i string, p str
}
-// GetAllGenericPlacementIntents returns all the generic placement intents for a given compsoite app name, composite app version and project.
-func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, ca string, v string) ([]GenericPlacementIntent, error) {
+// GetAllGenericPlacementIntents returns all the generic placement intents for a given compsoite app name, composite app version, project and deploymentIntentGroupName
+func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, ca string, v string, digName string) ([]GenericPlacementIntent, error) {
//Check if project exists
_, err := NewProjectClient().GetProject(p)
@@ -170,6 +177,8 @@ func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, c
Project: p,
CompositeApp: ca,
Version: v,
+ DigName: digName,
+
}
var gpList []GenericPlacementIntent
@@ -192,12 +201,13 @@ func (c *GenericPlacementIntentClient) GetAllGenericPlacementIntents(p string, c
}
// DeleteGenericPlacementIntent the intent from the database
-func (c *GenericPlacementIntentClient) DeleteGenericPlacementIntent(i string, p string, ca string, v string) error {
+func (c *GenericPlacementIntentClient) DeleteGenericPlacementIntent(i string, p string, ca string, v string, digName string) error {
key := GenericPlacementIntentKey{
Name: i,
Project: p,
CompositeApp: ca,
Version: v,
+ DigName: digName,
}
err := db.DBconn.Remove(c.storeName, key)
diff --git a/src/orchestrator/pkg/module/generic_placement_intent_test.go b/src/orchestrator/pkg/module/generic_placement_intent_test.go
index d779e81f..59c1cac5 100644
--- a/src/orchestrator/pkg/module/generic_placement_intent_test.go
+++ b/src/orchestrator/pkg/module/generic_placement_intent_test.go
@@ -31,6 +31,7 @@ func TestCreateGenericPlacementIntent(t *testing.T) {
inputProject string
inputCompositeApp string
inputCompositeAppVersion string
+ inputDepIntGrpName string
expectedError string
mockdb *db.MockDB
expected GenericPlacementIntent
@@ -44,13 +45,11 @@ func TestCreateGenericPlacementIntent(t *testing.T) {
UserData1: "userData1",
UserData2: "userData2",
},
- Spec: GenIntentSpecData{
- LogicalCloud: "logicalCloud1",
- },
},
inputProject: "testProject",
inputCompositeApp: "testCompositeApp",
inputCompositeAppVersion: "testCompositeAppVersion",
+ inputDepIntGrpName: "testDeploymentIntentGroup",
expected: GenericPlacementIntent{
MetaData: GenIntentMetaData{
Name: "testGenericPlacement",
@@ -58,9 +57,6 @@ func TestCreateGenericPlacementIntent(t *testing.T) {
UserData1: "userData1",
UserData2: "userData2",
},
- Spec: GenIntentSpecData{
- LogicalCloud: "logicalCloud1",
- },
},
expectedError: "",
mockdb: &db.MockDB{
@@ -82,6 +78,40 @@ func TestCreateGenericPlacementIntent(t *testing.T) {
"\"spec\":{" +
"\"version\":\"version of the composite app\"}}"),
},
+ DeploymentIntentGroupKey{
+ Name: "testDeploymentIntentGroup",
+ Project: "testProject",
+ CompositeApp: "testCompositeApp",
+ Version: "testCompositeAppVersion",
+ }.String(): {
+ "deploymentintentgroupmetadata": []byte(
+ "{\"metadata\":{\"name\":\"testDeploymentIntentGroup\"," +
+ "\"description\":\"DescriptionTestDeploymentIntentGroup\"," +
+ "\"userData1\": \"userData1\"," +
+ "\"userData2\": \"userData2\"}," +
+ "\"spec\":{\"profile\": \"Testprofile\"," +
+ "\"version\": \"version of deployment\"," +
+ "\"override-values\":[" +
+ "{" +
+ "\"app-name\": \"TestAppName\"," +
+ "\"values\": " +
+ "{" +
+ "\"imageRepository\":\"registry.hub.docker.com\"" +
+ "}" +
+ "}," +
+ "{" +
+ "\"app-name\": \"TestAppName\"," +
+ "\"values\": " +
+ "{" +
+ "\"imageRepository\":\"registry.hub.docker.com\"" +
+ "}" +
+ "}" +
+ "]," +
+ "\"logical-cloud\": \"cloud1\"" +
+ "}"+
+ "}"),
+ },
+
},
},
},
@@ -91,7 +121,7 @@ func TestCreateGenericPlacementIntent(t *testing.T) {
t.Run(testCase.label, func(t *testing.T) {
db.DBconn = testCase.mockdb
intentCli := NewGenericPlacementIntentClient()
- got, err := intentCli.CreateGenericPlacementIntent(testCase.inputIntent, testCase.inputProject, testCase.inputCompositeApp, testCase.inputCompositeAppVersion)
+ got, err := intentCli.CreateGenericPlacementIntent(testCase.inputIntent, testCase.inputProject, testCase.inputCompositeApp, testCase.inputCompositeAppVersion, testCase.inputDepIntGrpName)
if err != nil {
if testCase.expectedError == "" {
t.Fatalf("CreateGenericPlacementIntent returned an unexpected error %s", err)
@@ -120,6 +150,7 @@ func TestGetGenericPlacementIntent(t *testing.T) {
projectName string
compositeAppName string
compositeAppVersion string
+ deploymentIntentGroupName string
}{
{
label: "Get Intent",
@@ -127,6 +158,7 @@ func TestGetGenericPlacementIntent(t *testing.T) {
projectName: "testProject",
compositeAppName: "testCompositeApp",
compositeAppVersion: "testVersion",
+ deploymentIntentGroupName: "testDeploymentIntentGroup",
expected: GenericPlacementIntent{
MetaData: GenIntentMetaData{
Name: "testIntent",
@@ -134,9 +166,6 @@ func TestGetGenericPlacementIntent(t *testing.T) {
UserData1: "userData1",
UserData2: "userData2",
},
- Spec: GenIntentSpecData{
- LogicalCloud: "logicalCloud1",
- },
},
expectedError: "",
mockdb: &db.MockDB{
@@ -146,13 +175,14 @@ func TestGetGenericPlacementIntent(t *testing.T) {
Project: "testProject",
CompositeApp: "testCompositeApp",
Version: "testVersion",
+ DigName: "testDeploymentIntentGroup",
}.String(): {
"genericplacementintentmetadata": []byte(
"{\"metadata\":{\"Name\":\"testIntent\"," +
"\"Description\":\"A sample intent for testing\"," +
"\"UserData1\": \"userData1\"," +
- "\"UserData2\": \"userData2\"}," +
- "\"spec\":{\"Logical-Cloud\": \"logicalCloud1\"}}"),
+ "\"UserData2\": \"userData2\"}" +
+ "}"),
},
},
},
@@ -163,7 +193,7 @@ func TestGetGenericPlacementIntent(t *testing.T) {
t.Run(testCase.label, func(t *testing.T) {
db.DBconn = testCase.mockdb
intentCli := NewGenericPlacementIntentClient()
- got, err := intentCli.GetGenericPlacementIntent(testCase.intentName, testCase.projectName, testCase.compositeAppName, testCase.compositeAppVersion)
+ got, err := intentCli.GetGenericPlacementIntent(testCase.intentName, testCase.projectName, testCase.compositeAppName, testCase.compositeAppVersion, testCase.deploymentIntentGroupName)
if err != nil {
if testCase.expectedError == "" {
t.Fatalf("GetGenericPlacementIntent returned an unexpected error: %s", err)
diff --git a/src/orchestrator/pkg/module/instantiation.go b/src/orchestrator/pkg/module/instantiation.go
index 0ae76006..4375a90b 100644
--- a/src/orchestrator/pkg/module/instantiation.go
+++ b/src/orchestrator/pkg/module/instantiation.go
@@ -338,7 +338,7 @@ func (c InstantiationClient) Instantiate(p string, ca string, v string, di strin
defer cleanTmpfiles(sortedTemplates)
- specData, err := NewAppIntentClient().GetAllIntentsByApp(eachApp.Metadata.Name, p, ca, v, gIntent)
+ specData, err := NewAppIntentClient().GetAllIntentsByApp(eachApp.Metadata.Name, p, ca, v, gIntent, di)
if err != nil {
deleteAppContext(context)
return pkgerrors.Wrap(err, "Unable to get the intents for app")