From febabe67e79ec9c79b7817157094594bea0c1663 Mon Sep 17 00:00:00 2001 From: mr Date: Tue, 23 Jul 2024 08:59:39 +0200 Subject: [PATCH] Not a proper WF model --- models/resources/workflow/workflow.go | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/models/resources/workflow/workflow.go b/models/resources/workflow/workflow.go index 87baffe..b1e6222 100644 --- a/models/resources/workflow/workflow.go +++ b/models/resources/workflow/workflow.go @@ -2,33 +2,27 @@ package oclib import ( "encoding/json" + "slices" "cloud.o-forge.io/core/oc-lib/models/resources" - "cloud.o-forge.io/core/oc-lib/models/resources/data" - "cloud.o-forge.io/core/oc-lib/models/resources/datacenter" - "cloud.o-forge.io/core/oc-lib/models/resources/processing" - "cloud.o-forge.io/core/oc-lib/models/resources/storage" "cloud.o-forge.io/core/oc-lib/models/resources/workflow/graph" "cloud.o-forge.io/core/oc-lib/models/utils" ) type AbstractWorkflow struct { - Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"` - Datas map[string]data.DataResource `bson:"datas,omitempty" json:"datas,omitempty"` - Storages map[string]storage.StorageResource `bson:"storages,omitempty" json:"storages,omitempty"` - ProcessingResource map[string]processing.ProcessingResource `bson:"processing,omitempty" json:"processing,omitempty"` - Datacenters map[string]datacenter.DatacenterResource `bson:"datacenters,omitempty" json:"datacenters,omitempty"` - Workflows map[string]WorkflowResource `bson:"workflows,omitempty" json:"workflows,omitempty"` - Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"` + Graph *graph.Graph `bson:"graph,omitempty" json:"graph,omitempty"` + Datas []string `bson:"datas,omitempty" json:"datas,omitempty"` + Storages []string `bson:"storages,omitempty" json:"storages,omitempty"` + ProcessingResource []string `bson:"processing,omitempty" json:"processing,omitempty"` + Datacenters []string `bson:"datacenters,omitempty" json:"datacenters,omitempty"` + Workflows []string `bson:"workflows,omitempty" json:"workflows,omitempty"` + Schedule *WorkflowSchedule `bson:"schedule,omitempty" json:"schedule,omitempty"` } func (w *AbstractWorkflow) isDCLink(link graph.GraphLink) bool { - if _, exists := w.Datacenters[link.Destination.ID]; exists { - return true - } else if _, exists := w.Datacenters[link.Source.ID]; exists { + if slices.Contains(w.Datacenters, link.Destination.ID) || slices.Contains(w.Datacenters, link.Source.ID) { return true } - return false }