Copy
This commit is contained in:
@@ -9,13 +9,13 @@ import (
|
|||||||
"cloud.o-forge.io/core/oc-lib/tools"
|
"cloud.o-forge.io/core/oc-lib/tools"
|
||||||
)
|
)
|
||||||
|
|
||||||
type computeUnitsMongoAccessor[T LiveInterface] struct {
|
type liveMongoAccessor[T LiveInterface] struct {
|
||||||
utils.AbstractAccessor[LiveInterface] // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
utils.AbstractAccessor[LiveInterface] // AbstractAccessor contains the basic fields of an accessor (model, caller)
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new instance of the computeUnitsMongoAccessor
|
// New creates a new instance of the computeUnitsMongoAccessor
|
||||||
func NewAccessor[T LiveInterface](t tools.DataType, request *tools.APIRequest) *computeUnitsMongoAccessor[T] {
|
func NewAccessor[T LiveInterface](t tools.DataType, request *tools.APIRequest) *liveMongoAccessor[T] {
|
||||||
return &computeUnitsMongoAccessor[T]{
|
return &liveMongoAccessor[T]{
|
||||||
AbstractAccessor: utils.AbstractAccessor[LiveInterface]{
|
AbstractAccessor: utils.AbstractAccessor[LiveInterface]{
|
||||||
Logger: logs.CreateLogger(t.String()), // Create a logger with the data type
|
Logger: logs.CreateLogger(t.String()), // Create a logger with the data type
|
||||||
Request: request,
|
Request: request,
|
||||||
@@ -36,7 +36,7 @@ func NewAccessor[T LiveInterface](t tools.DataType, request *tools.APIRequest) *
|
|||||||
/*
|
/*
|
||||||
* Nothing special here, just the basic CRUD operations
|
* Nothing special here, just the basic CRUD operations
|
||||||
*/
|
*/
|
||||||
func (a *computeUnitsMongoAccessor[T]) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
func (a *liveMongoAccessor[T]) CopyOne(data utils.DBObject) (utils.DBObject, int, error) {
|
||||||
// is a publisher... that become a resources.
|
// is a publisher... that become a resources.
|
||||||
if data.IsDrafted() {
|
if data.IsDrafted() {
|
||||||
return nil, 422, errors.New("can't publish a drafted compute units")
|
return nil, 422, errors.New("can't publish a drafted compute units")
|
||||||
|
|||||||
@@ -207,7 +207,8 @@ func (d *Workflow) generateResource(datas []resources.ResourceInterface, request
|
|||||||
json.Unmarshal(b, &liv)
|
json.Unmarshal(b, &liv)
|
||||||
data, _, err := access.StoreOne(&liv)
|
data, _, err := access.StoreOne(&liv)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
access.CopyOne(data)
|
_, _, err := access.CopyOne(data)
|
||||||
|
fmt.Println("COPY ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
@@ -218,7 +219,8 @@ func (d *Workflow) generateResource(datas []resources.ResourceInterface, request
|
|||||||
json.Unmarshal(b, &liv)
|
json.Unmarshal(b, &liv)
|
||||||
data, _, err := access.StoreOne(&liv)
|
data, _, err := access.StoreOne(&liv)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
access.CopyOne(data)
|
_, _, err := access.CopyOne(data)
|
||||||
|
fmt.Println("COPY ", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
|
|||||||
Reference in New Issue
Block a user