(ctx context.Context, owner string, hook *github.Hook)
| 64 | } |
| 65 | |
| 66 | func (g *githubClient) createGiteaOrgHook(ctx context.Context, owner string, hook *github.Hook) (ret *github.Hook, err error) { |
| 67 | u := fmt.Sprintf("orgs/%v/hooks", owner) |
| 68 | createOpts := &createGiteaHookOptions{ |
| 69 | Type: "gitea", |
| 70 | Events: hook.Events, |
| 71 | Active: hook.GetActive(), |
| 72 | BranchFilter: "*", |
| 73 | Config: map[string]string{ |
| 74 | "content_type": hook.GetConfig().GetContentType(), |
| 75 | "url": hook.GetConfig().GetURL(), |
| 76 | "http_method": "post", |
| 77 | "secret": hook.GetConfig().GetSecret(), |
| 78 | }, |
| 79 | } |
| 80 | |
| 81 | req, err := g.cli.NewRequest(http.MethodPost, u, createOpts) |
| 82 | if err != nil { |
| 83 | return nil, fmt.Errorf("failed to construct request: %w", err) |
| 84 | } |
| 85 | |
| 86 | hook = new(github.Hook) |
| 87 | _, err = g.cli.Do(ctx, req, hook) |
| 88 | if err != nil { |
| 89 | return nil, fmt.Errorf("request failed for %s: %w", req.URL.String(), err) |
| 90 | } |
| 91 | return hook, nil |
| 92 | } |
| 93 | |
| 94 | func (g *githubClient) createGiteaEntityHook(ctx context.Context, hook *github.Hook) (ret *github.Hook, err error) { |
| 95 | metrics.GithubOperationCount.WithLabelValues( |
no test coverage detected