MCPcopy Create free account
hub / github.com/cloudbase/garm / createGiteaRepoHook

Method createGiteaRepoHook

util/github/gitea.go:38–64  ·  view source on GitHub ↗
(ctx context.Context, owner, name string, hook *github.Hook)

Source from the content-addressed store, hash-verified

36}
37
38func (g *githubClient) createGiteaRepoHook(ctx context.Context, owner, name string, hook *github.Hook) (ret *github.Hook, err error) {
39 u := fmt.Sprintf("repos/%v/%v/hooks", owner, name)
40 createOpts := &createGiteaHookOptions{
41 Type: "gitea",
42 Events: hook.Events,
43 Active: hook.GetActive(),
44 BranchFilter: "*",
45 Config: map[string]string{
46 "content_type": hook.GetConfig().GetContentType(),
47 "url": hook.GetConfig().GetURL(),
48 "http_method": "post",
49 "secret": hook.GetConfig().GetSecret(),
50 },
51 }
52
53 req, err := g.cli.NewRequest(http.MethodPost, u, createOpts)
54 if err != nil {
55 return nil, fmt.Errorf("failed to construct request: %w", err)
56 }
57
58 hook = new(github.Hook)
59 _, err = g.cli.Do(ctx, req, hook)
60 if err != nil {
61 return nil, fmt.Errorf("request failed for %s: %w", req.URL.String(), err)
62 }
63 return hook, nil
64}
65
66func (g *githubClient) createGiteaOrgHook(ctx context.Context, owner string, hook *github.Hook) (ret *github.Hook, err error) {
67 u := fmt.Sprintf("orgs/%v/hooks", owner)

Callers 1

createGiteaEntityHookMethod · 0.95

Calls 4

NewRequestMethod · 0.80
DoMethod · 0.80
GetURLMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected