From 46943a9a489cd0ae0a63abb3d4f360835ddd1b46 Mon Sep 17 00:00:00 2001
From: Yordan Kinkov <yordan.kinkov@vereign.com>
Date: Tue, 7 Jun 2022 14:49:14 +0300
Subject: [PATCH] #13 task list executor function fix

---
 docs/new.json                         | 22 ----------------------
 internal/listexecutor/listexecutor.go |  7 +++----
 2 files changed, 3 insertions(+), 26 deletions(-)
 delete mode 100644 docs/new.json

diff --git a/docs/new.json b/docs/new.json
deleted file mode 100644
index 69e0216..0000000
--- a/docs/new.json
+++ /dev/null
@@ -1,22 +0,0 @@
-{
-  "name": "example",
-  "cacheNamespace": "login",
-  "cacheScope": "user",
-  "groups": [
-    {
-      "execution": "sequential",
-      "tasks": [
-        "task1",
-        "task2"
-      ]
-    },
-    {
-      "execution": "parallel",
-      "tasks": [
-        "task3",
-        "task4",
-        "task5"
-      ]
-    }
-  ]
-}
\ No newline at end of file
diff --git a/internal/listexecutor/listexecutor.go b/internal/listexecutor/listexecutor.go
index a2a4db6..fd0247a 100644
--- a/internal/listexecutor/listexecutor.go
+++ b/internal/listexecutor/listexecutor.go
@@ -123,13 +123,12 @@ func (l *ListExecutor) Execute(ctx context.Context, list *tasklist.TaskList) {
 	list.StartTime = time.Now()
 
 	// execute groups sequentially
-	for i, group := range list.Groups {
-		if err := l.executeGroup(ctx, &group); err != nil {
+	for i, _ := range list.Groups {
+		if err := l.executeGroup(ctx, &list.Groups[i]); err != nil {
 			logger.Error("error executing group", zap.Error(err))
-			group.State = taskpkg.Failed
+			list.Groups[i].State = taskpkg.Failed
 			list.State = taskpkg.Failed
 		}
-		list.Groups[i] = group
 	}
 
 	if list.State != taskpkg.Failed {
-- 
GitLab