summaryrefslogtreecommitdiffstats
path: root/src/orchestrator/pkg/module/app_intent.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/orchestrator/pkg/module/app_intent.go')
-rw-r--r--src/orchestrator/pkg/module/app_intent.go117
1 files changed, 65 insertions, 52 deletions
diff --git a/src/orchestrator/pkg/module/app_intent.go b/src/orchestrator/pkg/module/app_intent.go
index 9da252e5..6b394513 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
@@ -67,20 +67,22 @@ type AppIntentQueryKey struct {
// AppIntentKey is used as primary key
type AppIntentKey struct {
- Name string `json:"appintent"`
- Project string `json:"project"`
- CompositeApp string `json:"compositeapp"`
- Version string `json:"compositeappversion"`
- Intent string `json:"genericplacement"`
+ Name string `json:"appintent"`
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ Version string `json:"compositeappversion"`
+ Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroup"`
}
// AppIntentFindByAppKey required for query
type AppIntentFindByAppKey struct {
- Project string `json:"project"`
- CompositeApp string `json:"compositeapp"`
- CompositeAppVersion string `json:"compositeappversion"`
- Intent string `json:"genericplacement"`
- AppName string `json:"app-name"`
+ Project string `json:"project"`
+ CompositeApp string `json:"compositeapp"`
+ CompositeAppVersion string `json:"compositeappversion"`
+ Intent string `json:"genericplacement"`
+ DeploymentIntentGroupName string `json:"deploymentintentgroup"`
+ AppName string `json:"app-name"`
}
// ApplicationsAndClusterInfo type represents the list of
@@ -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,
+ Name: a.MetaData.Name,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
+ DeploymentIntentGroupName: digName,
}
qkey := AppIntentQueryKey{
@@ -168,15 +177,16 @@ func (c *AppIntentClient) CreateAppIntent(a AppIntent, p string, ca string, v st
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,
- Project: p,
- CompositeApp: ca,
- Version: v,
- Intent: i,
+ Name: ai,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
+ DeploymentIntentGroupName: digName,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
@@ -197,17 +207,18 @@ 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,
- AppName: aN,
+ Project: p,
+ CompositeApp: ca,
+ CompositeAppVersion: v,
+ Intent: i,
+ DeploymentIntentGroupName: digName,
+ AppName: aN,
}
result, err := db.DBconn.Find(c.storeName, k, c.tagMetaData)
if err != nil {
@@ -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,
+ 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,
+ Name: ai,
+ Project: p,
+ CompositeApp: ca,
+ Version: v,
+ Intent: i,
+ DeploymentIntentGroupName: digName,
}
err := db.DBconn.Remove(c.storeName, k)