in pkg/gitprovider/gitlab.go [45:83]
func (c *GitLabClient) CreateWebHook(
ctx context.Context,
gitlabURL,
token,
projectID,
webHookSecret,
webHookURL string,
skipTLS bool,
) (*WebHook, error) {
c.restyClient.HostURL = gitlabURL
webHook := &gitlabWebHook{}
resp, err := c.restyClient.
R().
SetContext(ctx).
SetHeader(gitLabTokenHeaderName, token).
SetBody(map[string]interface{}{
"url": webHookURL,
"merge_requests_events": true,
"note_events": true,
"push_events": false,
"token": webHookSecret,
"enable_ssl_verification": !skipTLS,
}).
SetPathParams(map[string]string{
projectIDPathParam: projectID,
}).
SetResult(webHook).
Post("/api/v4/projects/{project-id}/hooks")
if err != nil {
return nil, fmt.Errorf("failed to create GitLab web hook: %w", err)
}
if resp.IsError() {
return nil, fmt.Errorf("failed to create GitLab web hook: %s", resp.String())
}
return convertGitlabWebhook(webHook), nil
}