diff --git a/models/booking/booking.go b/models/booking/booking.go index 831f443..4136625 100644 --- a/models/booking/booking.go +++ b/models/booking/booking.go @@ -6,7 +6,6 @@ import ( "cloud.o-forge.io/core/oc-lib/dbs" "cloud.o-forge.io/core/oc-lib/models/common/enum" "cloud.o-forge.io/core/oc-lib/models/common/models" - "cloud.o-forge.io/core/oc-lib/models/common/pricing" "cloud.o-forge.io/core/oc-lib/models/utils" "cloud.o-forge.io/core/oc-lib/tools" "go.mongodb.org/mongo-driver/bson/primitive" @@ -16,10 +15,10 @@ import ( * Booking is a struct that represents a booking */ type Booking struct { - utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) - PricedItem pricing.PricedItemITF `json:"priced_item,omitempty" bson:"priced_item,omitempty"` // We need to add the validate:"required" tag once the pricing feature is implemented, removed to avoid handling the error + utils.AbstractObject // AbstractObject contains the basic fields of an object (id, name) + PricedItem map[string]interface{} `json:"priced_item,omitempty" bson:"priced_item,omitempty"` // We need to add the validate:"required" tag once the pricing feature is implemented, removed to avoid handling the error - ResumeMetrics map[string]map[string]models.MetricResume `json:"resume_metrics,omitempty" bson:"resume_metrics,omitempty"` + ResumeMetrics map[string]map[string]models.MetricResume `json:"resume_metrics,omitempty" bson:"resume_metrics,omitempty"` ExecutionMetrics map[string][]models.MetricsSnapshot `json:"metrics,omitempty" bson:"metrics,omitempty"` ExecutionsID string `json:"executions_id,omitempty" bson:"executions_id,omitempty" validate:"required"` // ExecutionsID is the ID of the executions diff --git a/models/workflow_execution/workflow_execution.go b/models/workflow_execution/workflow_execution.go index 39ef327..6bb2818 100755 --- a/models/workflow_execution/workflow_execution.go +++ b/models/workflow_execution/workflow_execution.go @@ -1,6 +1,7 @@ package workflow_execution import ( + "encoding/json" "strings" "time" @@ -141,13 +142,16 @@ func (d *WorkflowExecution) buyEach(bs pricing.BillingStrategy, executionsID str if s := priced.GetLocationStart(); s != nil { start = *s } + var m map[string]interface{} + b, _ := json.Marshal(priced) + json.Unmarshal(b, &m) end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second) bookingItem := &purchase_resource.PurchaseResource{ AbstractObject: utils.AbstractObject{ UUID: uuid.New().String(), Name: d.GetName() + "_" + executionsID + "_" + wfID, }, - PricedItem: priced, + PricedItem: m, ExecutionsID: executionsID, DestPeerID: priced.GetCreatorID(), ResourceID: priced.GetID(), @@ -189,12 +193,15 @@ func (d *WorkflowExecution) bookEach(executionsID string, wfID string, dt tools. start = *s } end := start.Add(time.Duration(priced.GetExplicitDurationInS()) * time.Second) + var m map[string]interface{} + b, _ := json.Marshal(priced) + json.Unmarshal(b, &m) bookingItem := &booking.Booking{ AbstractObject: utils.AbstractObject{ UUID: uuid.New().String(), Name: d.GetName() + "_" + executionsID + "_" + wfID, }, - PricedItem: priced, + PricedItem: m, ExecutionsID: executionsID, State: enum.SCHEDULED, ResourceID: priced.GetID(),