MCPcopy Index your code
hub / github.com/crashappsec/github-analyzer / GetWebhooks

Method GetWebhooks

pkg/github/org/org.go:86–117  ·  view source on GitHub ↗

GetWebhook returns the webhooks for a given org. Upon first call, it lazily updates the Organization with the webhook information

(
	ctx context.Context)

Source from the content-addressed store, hash-verified

84// GetWebhook returns the webhooks for a given org. Upon first call,
85// it lazily updates the Organization with the webhook information
86func (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
119func (org *Organization) GetInstalls(
120 ctx context.Context) (map[types.InstallID]types.Install, error) {

Callers 1

AuditWebhooksMethod · 0.95

Calls 1

GetPaginatedResultFunction · 0.92

Tested by

no test coverage detected