improved structure, doc and naming
This commit is contained in:
@@ -6,6 +6,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
@@ -13,16 +14,13 @@ import (
|
||||
)
|
||||
|
||||
type ArgoBuilder struct {
|
||||
graph Graph
|
||||
graph Graph
|
||||
branches [][]string
|
||||
steps []DagStep
|
||||
Workflow Workflow
|
||||
}
|
||||
|
||||
type DagStep struct {
|
||||
Name string `yaml:"name"`
|
||||
Template string `yaml:"template"`
|
||||
Arguments []string `yaml:"arguments"`
|
||||
Dependencies []string `yaml:"dependencies"`
|
||||
type Workflow struct {
|
||||
Templates []Template `yaml:"templates"`
|
||||
}
|
||||
|
||||
|
||||
@@ -31,22 +29,32 @@ func (b *ArgoBuilder) CreateDAG() bool {
|
||||
fmt.Println("list of branches : ", b.branches)
|
||||
|
||||
b.createDAGstep()
|
||||
yamlified, err := yaml.Marshal(b.steps)
|
||||
yamlified, err := yaml.Marshal(b.Workflow)
|
||||
|
||||
if err != nil {
|
||||
logs.Error("Could not produce yaml file")
|
||||
logs.Error("Could not transform object to yaml file")
|
||||
}
|
||||
fmt.Println(string(yamlified))
|
||||
|
||||
err = os.WriteFile("argo.yml", []byte(yamlified), 0660)
|
||||
if err != nil {
|
||||
logs.Error("Could not write the yaml file")
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
|
||||
func (b *ArgoBuilder) createDAGstep() {
|
||||
|
||||
new_dag := Dag{}
|
||||
|
||||
for _, comp := range b.graph.Computings{
|
||||
unique_name := comp.Name + "_" + comp.ID
|
||||
step := DagStep{Name: unique_name, Template: unique_name, Arguments: comp.Arguments}
|
||||
var comp_params []Parameter
|
||||
comp_params = append(comp_params, Parameter{"toto","titi"})
|
||||
step := Task{Name: unique_name, Template: unique_name}
|
||||
step.Arguments.Parameters = append(step.Arguments.Parameters, comp_params...)
|
||||
|
||||
// For each branch, check if the computing has a dependency
|
||||
for _, branch := range b.branches {
|
||||
if b.componentInBranch(comp.ID,branch) {
|
||||
@@ -57,8 +65,13 @@ func (b *ArgoBuilder) createDAGstep() {
|
||||
}
|
||||
}
|
||||
}
|
||||
b.steps = append(b.steps, step)
|
||||
|
||||
new_dag.Tasks = append(new_dag.Tasks, step)
|
||||
|
||||
}
|
||||
|
||||
b.Workflow.Templates = append (b.Workflow.Templates, Template{Name: "dag", Dag: new_dag})
|
||||
|
||||
}
|
||||
|
||||
func (b *ArgoBuilder) getDependency (current_computing_id string, branch []string) string {
|
||||
|
||||
Reference in New Issue
Block a user