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

Method createGiteaOrgHook

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

Source from the content-addressed store, hash-verified

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)
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
94func (g *githubClient) createGiteaEntityHook(ctx context.Context, hook *github.Hook) (ret *github.Hook, err error) {
95 metrics.GithubOperationCount.WithLabelValues(

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