plugins

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const AboutThisBotWithoutCommands = "" /* 299-byte string literal not displayed */

AboutThisBotWithoutCommands contains the message that explains how to interact with the bot.

Variables

This section is empty.

Functions

func CleanMarkdownComments

func CleanMarkdownComments(body string) string

func FormatResponse

func FormatResponse(to, message, reason string) string

FormatResponse nicely formats a response to a generic reason.

func FormatResponseRaw

func FormatResponseRaw(body, bodyURL, login, reply string) string

FormatResponseRaw nicely formats a response for one does not have an issue comment

func RegisterGitCommentPlugin

func RegisterGitCommentPlugin(name string, builder GitCommentPluginBuilder)

func RegisterGitPRPlugin

func RegisterGitPRPlugin(name string, builder GitPRPluginBuilder)

Types

type Configuration

type Configuration struct {
	Owner   string                `json:"owner"`
	Repo    string                `json:"repo"`
	Plugins []PluginConfiguration `json:"plugins"`
}

Config

plugins:
  label:
  - --known-values=aaa,bbb,ccc

type GitBranch

type GitBranch struct {
	Ref string
	SHA string
}

type GitCheckConclusion

type GitCheckConclusion = string
const (
	GitCheckConclusionStateActionRequired GitCheckConclusion = "ACTION_REQUIRED" // The check suite or run requires action.
	GitCheckConclusionStateCancelled      GitCheckConclusion = "CANCELLED"       // The check suite or run has been cancelled.
	GitCheckConclusionStateFailure        GitCheckConclusion = "FAILURE"         // The check suite or run has failed.
	GitCheckConclusionStateNeutral        GitCheckConclusion = "NEUTRAL"         // The check suite or run was neutral.
	GitCheckConclusionStateSuccess        GitCheckConclusion = "SUCCESS"         // The check suite or run has succeeded.
	GitCheckConclusionStateSkipped        GitCheckConclusion = "SKIPPED"         // The check suite or run was skipped.
	GitCheckConclusionStateStale          GitCheckConclusion = "STALE"           // The check suite or run was marked stale by GitHub. Only GitHub can use this conclusion.
	GitCheckConclusionStateTimedOut       GitCheckConclusion = "TIMED_OUT"       // The check suite or run has timed out.
)

The possible states for a check suite or run conclusion.

type GitCheckStatus

type GitCheckStatus = string
const (
	GitCheckStatusCompleted  GitCheckStatus = "COMPLETED"   // The check run has been completed.
	GitCheckStatusInProgress GitCheckStatus = "IN_PROGRESS" // The check run is in progress.
	GitCheckStatusQueued     GitCheckStatus = "QUEUED"      // The check run has been queued.
)

The possible states of a check run in a status rollup.

type GitComment

type GitComment struct {
	ID           int    `json:"id"`
	NodeID       string `json:"node_id"`
	CommentID    int
	IsPR         bool
	Body         string
	HTMLURL      string
	Number       int
	User         GitUser
	IssueAuthor  GitUser
	Assignees    []GitUser
	IssueState   string
	IssueTitle   string
	IssueBody    string
	IssueHTMLURL string
}

type GitCommentEvent

type GitCommentEvent struct {
	GitComment

	Action GitCommentEventAction

	Repo GitRepo
}

GitCommentEvent is a fake event type that is instantiated for any git event that contains comment like content. The specific events that are also handled as GenericCommentEvents are: - issue_comment events - pull_request_review events - pull_request_review_comment events - pull_request events with action in ["opened", "edited"] - issue events with action in ["opened", "edited"]

Issue and PR "closed" events are not coerced to the "deleted" Action and do not trigger a GenericCommentEvent because these events don't actually remove the comment content from GH.

type GitCommentEventAction

type GitCommentEventAction string

GitCommentEventAction coerces multiple actions into its generic equivalent.

const (
	// GitCommentActionCreated means something was created/opened/submitted
	GitCommentActionCreated GitCommentEventAction = "created" // "opened", "submitted"
	// GitCommentActionEdited means something was edited.
	GitCommentActionEdited GitCommentEventAction = "edited"
	// GitCommentActionDeleted means something was deleted/dismissed.
	GitCommentActionDeleted GitCommentEventAction = "deleted" // "dismissed"
)

Comments indicate values that are coerced to the specified value.

type GitCommentPlugin

type GitCommentPlugin interface {
	Plugin
	Do(context.Context, GitCommentEvent) error
}

func GetGitCommentPlugin

func GetGitCommentPlugin(name string, clientSets ClientSets, args ...string) GitCommentPlugin

type GitCommentPluginBuilder

type GitCommentPluginBuilder func(ClientSets) GitCommentPlugin

GitComment plugin

type GitCommit

type GitCommit struct {
	Sha      string
	Statuses []GitCommitStatus
	Checks   []GitCommitCheck
}

type GitCommitCheck

type GitCommitCheck struct {
	Name       string
	Status     GitCheckStatus
	Conclusion GitCheckConclusion
}

type GitCommitFile

type GitCommitFile struct {
	Path string
}

type GitCommitStatus

type GitCommitStatus struct {
	Context     string
	State       GitStatusState
	TargetURL   string
	Description string
}

type GitIssue

type GitIssue struct {
	ID        int
	Number    int
	State     string
	Locked    bool
	Title     string
	Body      string
	Labels    []Label
	Assignees []GitUser
	User      GitUser
}

type GitIssueClient

type GitIssueClient interface {
	CreateIssueComment(context.Context, GitRepo, GitIssue, GitIssueComment) error
	AddLabel(context.Context, GitRepo, GitIssue, []Label) error
	RemoveLabel(context.Context, GitRepo, GitIssue, Label) error
}

type GitIssueComment

type GitIssueComment struct {
	ID   int
	Body string
	User GitUser
	URL  string
}

type GitIssueCommentEvent

type GitIssueCommentEvent struct {
	GitIssueComment

	Action GitCommentEventAction

	Issue GitIssue
	Repo  GitRepo
}

type GitMergeableState

type GitMergeableState = string
const (
	GitMergeableStateMergeable   GitMergeableState = "MERGEABLE"   // The pull request can be merged.
	GitMergeableStateConflicting GitMergeableState = "CONFLICTING" // The pull request cannot be merged due to merge conflicts.
	GitMergeableStateUnknown     GitMergeableState = "UNKNOWN"     // The mergeability of the pull request is still being calculated.
)

Whether or not a PullRequest can be merged.

type GitPRClient

type GitPRClient interface {
	ListFiles(context.Context, GitRepo, GitPullRequest) ([]GitCommitFile, error)
	GetPR(ctx context.Context, repo GitRepo, number int) (GitPullRequest, error)
	MergePR(ctx context.Context, repo GitRepo, number int, method string) error
}

type GitPREvent

type GitPREvent struct {
	GitPullRequest

	Action GitPREventAction
	Repo   GitRepo
}

type GitPREventAction

type GitPREventAction string

GitPREventAction coerces multiple actions into its generic equivalent.

const (
	// GitPRActionCreated means something was created/opened/submitted
	GitPRActionCreated GitPREventAction = "created" // "opened", "submitted"
	// GitPRActionEdited means something was edited.
	GitPRActionEdited GitPREventAction = "edited"
	// v means something was deleted/dismissed.
	GitPRActionDeleted GitPREventAction = "deleted" // "dismissed"
)

type GitPRPlugin

type GitPRPlugin interface {
	Plugin
	Do(context.Context, GitPREvent) error
}

func GetGitPRPlugin

func GetGitPRPlugin(name string, clientSets ClientSets, args ...string) GitPRPlugin

type GitPRPluginBuilder

type GitPRPluginBuilder func(ClientSets) GitPRPlugin

GitPR plugin

type GitPullRequest

type GitPullRequest struct {
	ID        int
	Number    int
	State     GitPullRequestState
	Head      GitBranch
	Locked    bool
	Title     string
	Body      string
	Mergeable GitMergeableState
	Labels    []Label
	Assignees []GitUser
	User      GitUser
}

type GitPullRequestSearchResult

type GitPullRequestSearchResult struct {
	GitPullRequest
	Commits []GitCommit
}

type GitPullRequestState

type GitPullRequestState = string
const (
	PullRequestStateOpen   GitPullRequestState = "OPEN"
	PullRequestStateClosed GitPullRequestState = "CLOSED"
	PullRequestStateMerged GitPullRequestState = "MERGED"
)

type GitRepo

type GitRepo struct {
	Name  string
	Owner GitUser
}

type GitRepoClient

type GitRepoClient interface {
	CreateStatus(ctx context.Context, repo GitRepo, ref string, status GitCommitStatus) error
	ListStatuses(ctx context.Context, repo GitRepo, ref string) ([]GitCommitStatus, error)
	ListChecks(ctx context.Context, repo GitRepo, ref string) ([]GitCommitCheck, error)
}

type GitSearchClient

type GitSearchClient interface {
	SearchPR(ctx context.Context, repo GitRepo, state string) ([]GitPullRequestSearchResult, error)
}

type GitStatusState

type GitStatusState = string
const (
	GitStatusStateExpected GitStatusState = "EXPECTED" // Status is expected.
	GitStatusStateError    GitStatusState = "ERROR"    // Status is errored.
	GitStatusStateFailure  GitStatusState = "FAILURE"  // Status is failing.
	GitStatusStatePending  GitStatusState = "PENDING"  // Status is pending.
	GitStatusStateSuccess  GitStatusState = "SUCCESS"  // Status is successful.
)

type GitUser

type GitUser struct {
	Name string
}

type Label

type Label struct {
	ID    int64
	Name  string
	Color string
}

type LoggerClient

type LoggerClient interface {
	GetLogger() logr.Logger
}

type OwnersClient

type OwnersClient interface {
	GetOwners(owner, repo, file string) (OwnersConfiguration, error)
}

type OwnersConfiguration

type OwnersConfiguration struct {
	Owner     string   `json:"owner"`
	Repo      string   `json:"repo"`
	Path      string   `json:"path"`
	Reviewers []string `json:"reviewers"`
	Approvers []string `json:"approvers"`
}

type Plugin

type Plugin interface {
	Name() string
	Description() string
	Usage() string
	BindFlags(flags *pflag.FlagSet)
}

type PluginConfigClient

type PluginConfigClient interface {
	GetConfig(owner, repo string) (Configuration, error)
}

type PluginConfiguration

type PluginConfiguration struct {
	Name string   `json:"name"`
	Args []string `json:"args"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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