GetWebhook returns the webhooks for a given org. Upon first call, it lazily updates the Organization with the webhook information
( ctx context.Context)
| 84 | // GetWebhook returns the webhooks for a given org. Upon first call, |
| 85 | // it lazily updates the Organization with the webhook information |
| 86 | func (org *Organization) GetWebhooks( |
| 87 | ctx context.Context) (map[types.WebhookID]types.Webhook, error) { |
| 88 | if len(org.Webhooks) > 0 { |
| 89 | return org.Webhooks, nil |
| 90 | } |
| 91 | |
| 92 | log.Logger.Debugf( |
| 93 | "Fetching webhooks for %s", |
| 94 | *org.info.Login, |
| 95 | ) |
| 96 | |
| 97 | opt := &github.ListOptions{PerPage: org.paginationSize} |
| 98 | hooks, err := utils.GetPaginatedResult( |
| 99 | ctx, |
| 100 | org.backoff, |
| 101 | opt, |
| 102 | func(opts *github.ListOptions) ([]*github.Hook, *github.Response, error) { |
| 103 | return org.client.Organizations.ListHooks(ctx, |
| 104 | *org.info.Login, |
| 105 | opt, |
| 106 | ) |
| 107 | }, |
| 108 | utils.WebhooksAggregator, |
| 109 | ) |
| 110 | |
| 111 | hookMap := make(map[types.WebhookID]types.Webhook, len(hooks)) |
| 112 | for _, h := range hooks { |
| 113 | hookMap[types.WebhookID(*h.ID)] = h |
| 114 | } |
| 115 | org.Webhooks = hookMap |
| 116 | return hookMap, err |
| 117 | } |
| 118 | |
| 119 | func (org *Organization) GetInstalls( |
| 120 | ctx context.Context) (map[types.InstallID]types.Install, error) { |
no test coverage detected