(ctx context.Context, id int64)
| 73 | } |
| 74 | |
| 75 | func (g *githubClient) GetEntityHook(ctx context.Context, id int64) (ret *github.Hook, err error) { |
| 76 | metrics.GithubOperationCount.WithLabelValues( |
| 77 | "GetHook", // label: operation |
| 78 | g.entity.LabelScope(), // label: scope |
| 79 | ).Inc() |
| 80 | defer func() { |
| 81 | if err != nil { |
| 82 | metrics.GithubOperationFailedCount.WithLabelValues( |
| 83 | "GetHook", // label: operation |
| 84 | g.entity.LabelScope(), // label: scope |
| 85 | ).Inc() |
| 86 | } |
| 87 | }() |
| 88 | var response *github.Response |
| 89 | switch g.entity.EntityType { |
| 90 | case params.ForgeEntityTypeRepository: |
| 91 | ret, response, err = g.repo.GetHook(ctx, g.entity.Owner, g.entity.Name, id) |
| 92 | case params.ForgeEntityTypeOrganization: |
| 93 | ret, response, err = g.org.GetHook(ctx, g.entity.Owner, id) |
| 94 | default: |
| 95 | return nil, errors.New("invalid entity type") |
| 96 | } |
| 97 | |
| 98 | if err == nil && response != nil { |
| 99 | g.recordLimits(response.Rate) |
| 100 | } |
| 101 | return ret, err |
| 102 | } |
| 103 | |
| 104 | func (g *githubClient) createGithubEntityHook(ctx context.Context, hook *github.Hook) (ret *github.Hook, err error) { |
| 105 | metrics.GithubOperationCount.WithLabelValues( |
nothing calls this directly
no test coverage detected