/
consuming.go
70 lines (46 loc) · 1.37 KB
/
consuming.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Copyright © 2023 Patrick Hermann patrick.hermann@sva.de
*/
package worker
import (
"fmt"
"os"
"time"
sthingsBase "github.com/stuttgart-things/sthingsBase"
sthingsK8s "github.com/stuttgart-things/sthingsK8s"
"sync"
)
var (
wg sync.WaitGroup
log = sthingsBase.StdOutFileLogger(logfilePath, "2006-01-02 15:04:05", 50, 3, 28)
)
func ConsumeRevisionRun(revisionRun map[int][]string) error {
clusterConfig, clusterConnection := sthingsK8s.GetKubeConfig(os.Getenv("KUBECONFIG"))
log.Info("Connected " + clusterConnection + " the cluster")
//CREATING AND WATCHING PRS
for i := 0; i < (len(revisionRun)); i++ {
log.Info("Stage: ", i)
for j, pr := range revisionRun[i] {
wg.Add(len(revisionRun) - 1)
log.Info("Concurrent pipelines for this stage:", len(revisionRun[i]))
// fmt.Println(pr)
renderedPipelineRun := pr
stage := i
pipeline := j
resourceName, _ := sthingsBase.GetRegexSubMatch(renderedPipelineRun, `name: "(.*?)"`)
go func() {
defer wg.Done()
sthingsK8s.CreateDynamicResourcesFromTemplate(clusterConfig, []byte(renderedPipelineRun), tektonNamespace)
time.Sleep(10 * time.Second)
log.Info("Stage: ", stage)
log.Info("Pipeline: ", pipeline)
log.Info("Verify for: ", resourceName)
VerifyPipelineRunStatus(resourceName)
}()
}
wg.Wait()
}
fmt.Println("END OF WATCH")
// os.Exit(0)
return nil
}