diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index 7d3fe07..e17048d 100644 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -2,6 +2,7 @@ package workflow_execution import ( "encoding/json" + "strings" "time" "cloud.o-forge.io/core/oc-lib/models/utils" @@ -45,6 +46,21 @@ type WorkflowExecution struct { WorkflowID string `json:"workflow_id" bson:"workflow_id,omitempty"` } +func (wfa *WorkflowExecution) ArgoStatusToState(status string) *WorkflowExecution { + status = strings.ToLower(status) + switch status { + case "succeeded": // Succeeded + wfa.State = int64(SUCCESS.EnumIndex()) + case "pending": // Pending + wfa.State = int64(SCHEDULED.EnumIndex()) + case "running": // Running + wfa.State = int64(STARTED.EnumIndex()) + default: // Failed + wfa.State = int64(FAILURE.EnumIndex()) + } + return wfa +} + func (ao *WorkflowExecution) GetID() string { return ao.UUID }