argostatus to state

This commit is contained in:
mr 2024-08-07 15:41:03 +02:00
parent 6df71bde1d
commit 0ec80473cc

View File

@ -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
}