(ctx context.Context, hook *github.Hook)
| 92 | } |
| 93 | |
| 94 | func (g *githubClient) createGiteaEntityHook(ctx context.Context, hook *github.Hook) (ret *github.Hook, err error) { |
| 95 | metrics.GithubOperationCount.WithLabelValues( |
| 96 | "CreateHook", // label: operation |
| 97 | g.entity.LabelScope(), // label: scope |
| 98 | ).Inc() |
| 99 | defer func() { |
| 100 | if err != nil { |
| 101 | metrics.GithubOperationFailedCount.WithLabelValues( |
| 102 | "CreateHook", // label: operation |
| 103 | g.entity.LabelScope(), // label: scope |
| 104 | ).Inc() |
| 105 | } |
| 106 | }() |
| 107 | switch g.entity.EntityType { |
| 108 | case params.ForgeEntityTypeRepository: |
| 109 | ret, err = g.createGiteaRepoHook(ctx, g.entity.Owner, g.entity.Name, hook) |
| 110 | case params.ForgeEntityTypeOrganization: |
| 111 | ret, err = g.createGiteaOrgHook(ctx, g.entity.Owner, hook) |
| 112 | default: |
| 113 | return nil, errors.New("invalid entity type") |
| 114 | } |
| 115 | return ret, err |
| 116 | } |
no test coverage detected