Skip to content

Commit

Permalink
feat (api): ensure default hooks config (#2114)
Browse files Browse the repository at this point in the history
Signed-off-by: Yvonnick Esnault <yvonnick.esnault@corp.ovh.com>
  • Loading branch information
yesnault authored and bnjjj committed Jan 31, 2018
1 parent 07c2c4c commit 89cd527
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion engine/api/workflow/dao_hook_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/go-gorp/gorp"

"github.com/ovh/cds/sdk"
"github.com/ovh/cds/sdk/log"
)

// Here are the default hooks
Expand Down Expand Up @@ -127,8 +128,15 @@ func CreateBuiltinWorkflowHookModels(db *gorp.DbMap) error {
}

if !ok {
log.Debug("CreateBuiltinWorkflowHookModels> inserting hooks config: %s", h.Name)
if err := InsertHookModel(tx, h); err != nil {
return sdk.WrapError(err, "CreateBuiltinWorkflowHookModels")
return sdk.WrapError(err, "CreateBuiltinWorkflowHookModels error on insert")
}
} else {
log.Debug("CreateBuiltinWorkflowHookModels> updating hooks config: %s", h.Name)
// update default values
if err := UpdateHookModel(tx, h); err != nil {
return sdk.WrapError(err, "CreateBuiltinWorkflowHookModels error on update")
}
}
}
Expand Down

0 comments on commit 89cd527

Please sign in to comment.