return b.Data rather than the whole b object

This commit is contained in:
pb 2025-07-09 12:07:54 +02:00
parent ad56c42c2f
commit 271d74b4dd

View File

@ -232,6 +232,8 @@ func (o *BookingController) Post() {
* - datacenter_resource_id: the id of the datacenter * - datacenter_resource_id: the id of the datacenter
* - workflow_execution: the workflow execution * - workflow_execution: the workflow execution
*/ */
logger := oclib.GetLogger()
logger.Info().Msg("Received a Booking")
var resp booking.Booking var resp booking.Booking
user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request) user, peerID, groups := oclib.ExtractTokenInfo(*o.Ctx.Request)
err := json.Unmarshal(o.Ctx.Input.CopyBody(10000000), &resp) err := json.Unmarshal(o.Ctx.Input.CopyBody(10000000), &resp)
@ -244,6 +246,7 @@ func (o *BookingController) Post() {
o.ServeJSON() o.ServeJSON()
return return
} }
if resp.ResourceType == tools.COMPUTE_RESOURCE { if resp.ResourceType == tools.COMPUTE_RESOURCE {
// later should check... health for any such as docker... // later should check... health for any such as docker...
res := oclib.NewRequest(oclib.LibDataEnum(oclib.COMPUTE_RESOURCE), user, peerID, groups, nil).LoadOne(resp.ResourceID) res := oclib.NewRequest(oclib.LibDataEnum(oclib.COMPUTE_RESOURCE), user, peerID, groups, nil).LoadOne(resp.ResourceID)
@ -311,12 +314,13 @@ func (o *BookingController) Post() {
}() }()
} }
logger.Info().Msg("Creating new namespace : " + resp.ExecutionsID)
if err := o.createNamespace(resp.ExecutionsID); err != nil { if err := o.createNamespace(resp.ExecutionsID); err != nil {
fmt.Println(err.Error()) fmt.Println(err.Error())
} }
o.Data["json"] = map[string]interface{}{ o.Data["json"] = map[string]interface{}{
"data": []interface{}{b}, "data": b.Data,
"code": 200, "code": 200,
"error": "", "error": "",
} }
@ -443,6 +447,15 @@ func (o *BookingController) createNamespace(ns string) error {
if err != nil { if err != nil {
return nil return nil
} }
ok, err := serv.GetNamespace(o.Ctx.Request.Context(), ns)
if ok == nil && err == nil {
return nil
}
if err != nil {
return err
}
err = serv.CreateNamespace(o.Ctx.Request.Context(), ns) err = serv.CreateNamespace(o.Ctx.Request.Context(), ns)
if err != nil { if err != nil {
return err return err