MCPcopy
hub / github.com/apache/devlake / postDeployments

Function postDeployments

backend/plugins/webhook/api/deployments.go:213–238  ·  view source on GitHub ↗
(input *plugin.ApiResourceInput, connection *models.WebhookConnection, err errors.Error)

Source from the content-addressed store, hash-verified

211}
212
213func postDeployments(input *plugin.ApiResourceInput, connection *models.WebhookConnection, err errors.Error) (*plugin.ApiResourceOutput, errors.Error) {
214 if err != nil {
215 return nil, err
216 }
217 // get request
218 request := &WebhookDeploymentReq{}
219 err = api.DecodeMapStruct(input.Body, request, true)
220 if err != nil {
221 return &plugin.ApiResourceOutput{Body: err.Error(), Status: http.StatusBadRequest}, nil
222 }
223 // validate
224 vld = validator.New()
225 err = errors.Convert(vld.Struct(request))
226 if err != nil {
227 return nil, errors.BadInput.Wrap(vld.Struct(request), `input json error`)
228 }
229 txHelper := dbhelper.NewTxHelper(basicRes, &err)
230 defer txHelper.End()
231 tx := txHelper.Begin()
232 if err := CreateDeploymentAndDeploymentCommits(connection, request, tx, logger); err != nil {
233 logger.Error(err, "create deployments")
234 return nil, err
235 }
236
237 return &plugin.ApiResourceOutput{Body: nil, Status: http.StatusOK}, nil
238}
239
240func CreateDeploymentAndDeploymentCommits(connection *models.WebhookConnection, request *WebhookDeploymentReq, tx dal.Transaction, logger log.Logger) errors.Error {
241 // validation

Callers 3

PostDeploymentsFunction · 0.85
PostDeploymentsByNameFunction · 0.85

Calls 7

WrapMethod · 0.80
EndMethod · 0.80
ErrorMethod · 0.65
NewMethod · 0.65
BeginMethod · 0.65
ConvertMethod · 0.45

Tested by

no test coverage detected