Documentation ¶
Overview ¶
Package commentpruner facilitates efficiently deleting bot comments as a reaction to webhook events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EventClient ¶
type EventClient struct {
// contains filtered or unexported fields
}
EventClient is a struct that provides bot comment deletion for an event related to an issue. A single client instance should be created for each event and shared by all consumers of the event. The client fetches the comments only once and filters that list repeatedly to find bot comments to delete. This avoids using lots of API tokens when fetching comments for each handler that wants to delete comments. (An HTTP cache only partially helps with this because deletions modify the list of comments so the next call requires GH to send the resource again.)
func NewEventClient ¶
func NewEventClient(ghc githubClient, log *logrus.Entry, org, repo string, number int) *EventClient
NewEventClient creates an EventClient struct. This should be used once per webhook event.
func (*EventClient) PruneComments ¶
func (c *EventClient) PruneComments(shouldPrune func(github.IssueComment) bool)
PruneComments fetches issue comments if they have not yet been fetched for this webhook event and then deletes any bot comments indicated by the func 'shouldPrune'.