-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathflow.go
48 lines (39 loc) · 1.18 KB
/
flow.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
package main
import (
"fmt"
"github.com/forj-oss/forjj-modules/trace"
)
// FlowInit load the flow in memory,
func (a *Forj) FlowInit() error {
// Load flows from Forjfile sources.
return a.flows.Load(a.f.GetDeclaredFlows()...)
}
// FlowApply apply flows to Forjfile
// it updates Forjfile inMemory object data.
func (a *Forj) FlowApply() error {
ffd := a.f.InMemForjfile()
bInError := false
defaultFlowToApply := "default"
if v, found, _ := a.f.Get("settings", "default", "flow"); found {
defaultFlowToApply = v.GetString()
}
if err := a.flows.Apply(defaultFlowToApply, nil, ffd); err != nil { // Applying Flow to Forjfile
gotrace.Error("Forjfile: %s", err)
bInError = true
}
for _, repo := range ffd.Repos {
flowToApply := defaultFlowToApply
if repo.Flow.Name != "" {
flowToApply = repo.Flow.Name
}
if err := a.flows.Apply(flowToApply, repo, ffd); err != nil { // Applying Flow to Forjfile repo
name , _ := repo.GetString("name")
gotrace.Error("Repo '%s': %s", name, err)
bInError = true
}
}
if bInError {
return fmt.Errorf("Several errors has been detected when trying to apply flows on Repositories. %s", "Please review and fix them.")
}
return nil
}