diff --git a/api/integration.go b/api/integration.go
index d56d5828..48a8f0ac 100644
--- a/api/integration.go
+++ b/api/integration.go
@@ -161,7 +161,7 @@ func ReceiveIntegration(w http.ResponseWriter, r *http.Request) {
continue
}
- RunIntegration(integration, project, r)
+ RunIntegration(integration, project, r, payload)
}
w.WriteHeader(http.StatusNoContent)
@@ -227,7 +227,7 @@ func MatchCompare(value interface{}, method db.IntegrationMatchMethodType, expec
}
}
-func RunIntegration(integration db.Integration, project db.Project, r *http.Request) {
+func RunIntegration(integration db.Integration, project db.Project, r *http.Request, payload []byte) {
log.Info(fmt.Sprintf("Running integration %d", integration.ID))
@@ -241,9 +241,8 @@ func RunIntegration(integration db.Integration, project db.Project, r *http.Requ
extractValues = append(extractValues, extractValuesForExtractor...)
- var extractedResults = Extract(extractValues, r)
+ var extractedResults = Extract(extractValues, r, payload)
- // XXX: LOG AN EVENT HERE
environmentJSONBytes, err := json.Marshal(extractedResults)
if err != nil {
log.Error(err)
@@ -256,15 +255,9 @@ func RunIntegration(integration db.Integration, project db.Project, r *http.Requ
ProjectID: integration.ProjectID,
Debug: true,
Environment: environmentJSONString,
+ Integration: true,
}
- //var user db.User
- //user, err = helpers.Store(r).GetUser(1)
- //if err != nil {
- // log.Error(err)
- // return
- //}
-
_, err = helpers.TaskPool(r).AddTask(taskDefinition, nil, integration.ProjectID)
if err != nil {
log.Error(err)
@@ -272,7 +265,7 @@ func RunIntegration(integration db.Integration, project db.Project, r *http.Requ
}
}
-func Extract(extractValues []db.IntegrationExtractValue, r *http.Request) (result map[string]string) {
+func Extract(extractValues []db.IntegrationExtractValue, r *http.Request, payload []byte) (result map[string]string) {
result = make(map[string]string)
for _, extractValue := range extractValues {
@@ -280,19 +273,12 @@ func Extract(extractValues []db.IntegrationExtractValue, r *http.Request) (resul
case db.IntegrationExtractHeaderValue:
result[extractValue.Variable] = r.Header.Get(extractValue.Key)
case db.IntegrationExtractBodyValue:
- bodyBytes, err := io.ReadAll(r.Body)
- if err != nil {
- log.Fatal(err)
- return
- }
- var body = string(bodyBytes)
-
switch extractValue.BodyDataType {
case db.IntegrationBodyDataJSON:
- result[extractValue.Variable] =
- fmt.Sprintf("%v", gojsonq.New().JSONString(body).Find(extractValue.Key))
+ var extractedResult = fmt.Sprintf("%v", gojsonq.New().JSONString(string(payload)).Find(extractValue.Key))
+ result[extractValue.Variable] = extractedResult
case db.IntegrationBodyDataString:
- result[extractValue.Variable] = body
+ result[extractValue.Variable] = string(payload)
}
}
}
diff --git a/db/Migration.go b/db/Migration.go
index 3bc33b19..9c8b9727 100644
--- a/db/Migration.go
+++ b/db/Migration.go
@@ -66,6 +66,7 @@ func GetMigrations() []Migration {
{Version: "2.9.61"},
{Version: "2.9.62"},
{Version: "2.9.70"},
+ {Version: "2.9.71"},
}
}
diff --git a/db/Task.go b/db/Task.go
index 307f943f..c213fde1 100644
--- a/db/Task.go
+++ b/db/Task.go
@@ -20,6 +20,8 @@ type Task struct {
DryRun bool `db:"dry_run" json:"dry_run"`
Diff bool `db:"diff" json:"diff"`
+ Integration bool `db:"integration" json:"integration"`
+
// override variables
Playbook string `db:"playbook" json:"playbook"`
Environment string `db:"environment" json:"environment"`
diff --git a/db/sql/migrations/v2.9.71.sql b/db/sql/migrations/v2.9.71.sql
new file mode 100644
index 00000000..17f12f84
--- /dev/null
+++ b/db/sql/migrations/v2.9.71.sql
@@ -0,0 +1 @@
+alter table `task` add integration boolean not null default false;
diff --git a/web/src/components/TaskLogView.vue b/web/src/components/TaskLogView.vue
index 0e2060a2..5e3bdd9a 100644
--- a/web/src/components/TaskLogView.vue
+++ b/web/src/components/TaskLogView.vue
@@ -23,10 +23,13 @@