From 0ec80473ccf72919c6aea7ec8325ae3ac8ef2221 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 7 Aug 2024 15:41:03 +0200 Subject: [PATCH] argostatus to state --- models/workflow_execution/workflow_execution.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 }