Documentation
¶
Index ¶
- Constants
- Variables
- func NewPREventHandler(minApprovals int) func(*github.PullRequestEvent, *github.Client, *slog.Logger)
- func NewProcessComment(minApprovals int) func(*github.IssueCommentEvent, *github.Client, *slog.Logger)
- func ProcessComment(event *github.IssueCommentEvent, client *github.Client, logger *slog.Logger)
- func RegisterEventHandlers(r *gin.Engine, client *github.Client, logger *slog.Logger, ...) func(string, []byte)
- type CommandDef
- type LabelDef
- type PREventDef
- type ProwGitHubClient
- type ProwLiteGitHubClient
Constants ¶
const ApprovalResetComment = "Approval has been reset since this PR was reopened."
ApprovalResetComment is posted when a PR is reopened to signal that previous approvals are void. countApprovals uses it as a marker to discard approvals granted before the reopen.
Variables ¶
var Commands = func() []CommandDef { table := buildDispatchTable(1) defs := make([]CommandDef, len(table)) for i, ch := range table { defs[i] = ch.def } return defs }()
Commands exposes the command definitions for doc generation.
var EventPluginLabels = []LabelDef{
{Name: "lgtm", Meaning: "PR has been approved."},
{Name: "do-not-merge", Meaning: "PR is not ready to merge."},
}
EventPluginLabels documents the labels used by the event plugin.
var PREvents = []PREventDef{
{
Action: "opened",
Behavior: "Adds `do-not-merge` label; creates LGTM check run with `neutral` conclusion.",
},
{
Action: "reopened",
Behavior: "Adds `do-not-merge`, removes `lgtm`, posts an approval-reset comment, and creates an LGTM check run with `neutral` conclusion.",
},
}
PREvents documents the pull_request webhook actions handled by the event plugin.
Functions ¶
func NewPREventHandler ¶ added in v0.4.0
func NewPREventHandler(minApprovals int) func(*github.PullRequestEvent, *github.Client, *slog.Logger)
NewPREventHandler returns a pull_request event handler configured with the given minimum approvals.
func NewProcessComment ¶ added in v0.4.0
func NewProcessComment(minApprovals int) func(*github.IssueCommentEvent, *github.Client, *slog.Logger)
NewProcessComment returns a ProcessComment function configured with the given minimum approvals.
func ProcessComment ¶
ProcessComment dispatches slash commands with a default of 1 required approval.
Types ¶
type CommandDef ¶ added in v0.3.0
type CommandDef struct {
// Triggers are the slash-command prefixes that activate this command.
Triggers []string
Description string
// Usage shows the full invocation syntax.
Usage string
}
CommandDef describes a slash command handled by the event plugin.
type PREventDef ¶ added in v0.3.0
PREventDef documents a pull_request webhook action handled by the event plugin.
type ProwGitHubClient ¶
type ProwGitHubClient interface {
GetClient() *github.Client
CreateCheckRun(ctx context.Context, owner, repo string, opt github.CreateCheckRunOptions) (*github.CheckRun, *github.Response, error)
}
ProwGitHubClient is the interface consumed by callers that need a GitHub client.
type ProwLiteGitHubClient ¶
type ProwLiteGitHubClient struct {
// contains filtered or unexported fields
}
ProwLiteGitHubClient wraps a GitHub client authenticated as a GitHub App installation.
func NewGithubClient ¶
func NewGithubClient(logger *slog.Logger) (*ProwLiteGitHubClient, error)
func (*ProwLiteGitHubClient) CreateCheckRun ¶
func (*ProwLiteGitHubClient) GetClient ¶
func (g *ProwLiteGitHubClient) GetClient() *github.Client