commentpruner

package
v1.12.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

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(spc scmProviderClient, 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(pr bool, shouldPrune func(*scm.Comment) 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'.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL