From eab5162389efbcfba5c7432e750a8ab4fb35e080 Mon Sep 17 00:00:00 2001 From: pb Date: Tue, 2 Jul 2024 12:24:23 +0200 Subject: [PATCH] minor fixes --- .gitignore | 3 +++ argo_builder.go | 12 ++++++++++-- graph.go | 5 +---- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index a1673b5..473eba8 100644 --- a/.gitignore +++ b/.gitignore @@ -22,3 +22,6 @@ go.work __debug_bin + +workflows_argo/ +*.xml \ No newline at end of file diff --git a/argo_builder.go b/argo_builder.go index 686aeca..6e68d27 100644 --- a/argo_builder.go +++ b/argo_builder.go @@ -9,6 +9,7 @@ import ( "os" "slices" "strings" + "time" "github.com/beego/beego/v2/core/logs" "github.com/nwtgck/go-fakelish" @@ -47,7 +48,8 @@ func (b *ArgoBuilder) CreateDAG() bool { b.Workflow.ApiVersion = "argoproj.io/v1alpha1" b.Workflow.Kind = "Workflow" - b.Workflow.Metadata.GenerateName = "oc-test-" + generateWfName() + random_name := generateWfName() + b.Workflow.Metadata.GenerateName = "oc-test-" + random_name yamlified, err := yaml.Marshal(b.Workflow) @@ -56,11 +58,17 @@ func (b *ArgoBuilder) CreateDAG() bool { return false } - err = os.WriteFile("argo.yml", []byte(yamlified), 0660) + // Give a unique name to each argo file with its timestamp DD:MM:YYYY_hhmmss + current_timestamp := time.Now().Format("02_01_2006_150405") + file_name := random_name + "_" + current_timestamp + ".yml" + workflows_dir := "workflows_argo/" + err = os.WriteFile(workflows_dir + file_name , []byte(yamlified), 0660) if err != nil { logs.Error("Could not write the yaml file") return false } + + fmt.Println("Created " + file_name) return true } diff --git a/graph.go b/graph.go index 0648a58..be04e11 100644 --- a/graph.go +++ b/graph.go @@ -13,10 +13,7 @@ import ( "github.com/tidwall/gjson" ) -type Link struct { - Src string - Dst string -} + type Graph struct { Datas []models.DataModel