externalplugins

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2021 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LabeledAction   = "labeled"
	UnlabeledAction = "unlabeled"
)

Allowed value of the action configuration of the label blocker plugin.

View Source
const (
	// LgtmLabelPrefix is the name of the lgtm label applied by the lgtm plugin.
	LgtmLabelPrefix = "status/LGT"

	// SigPrefix is a default sig label prefix.
	SigPrefix = "sig/"
)
View Source
const (
	// ContributionLabel is the name of the contribution label applied by the contribution plugin.
	ContributionLabel = "contribution"
	// FirstTimeContributorLabel is the name of the first-time-contributor label applied by the contribution plugin.
	FirstTimeContributorLabel = "first-time-contributor"
)

AboutThisBot contains the text of both AboutThisBotWithoutCommands and AboutThisBotCommands.

View Source
const AboutThisBotCommands = "I understand the commands that are listed [here](https://prow.tidb.io/command-help)."

AboutThisBotCommands contains the message that links to the commands the bot understand.

View Source
const AboutThisBotWithoutCommands = "Instructions for interacting with me using PR comments are available " +
	"[here](https://prow.tidb.io/command-help).  " +
	"If you have questions or suggestions related to my behavior, " +
	"please file an issue against the " +
	"[ti-community-infra/tichi]" +
	"(https://github.com/ti-community-infra/tichi/issues/new?title=Prow%20issue:) repository."

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

View Source
const (
	// CanMergeLabel is the name of the merge label applied by the merge plugin.
	CanMergeLabel = "status/can-merge"
)
View Source
const (
	// DefaultCherryPickLabelPrefix defines the default label prefix for cherrypicker plugin.
	DefaultCherryPickLabelPrefix = "cherrypick/"
)

Variables

This section is empty.

Functions

func FormatICResponse

func FormatICResponse(ic github.IssueComment, s string) string

FormatICResponse nicely formats a response to an issue comment.

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 FormatSimpleResponse

func FormatSimpleResponse(to, message string) string

FormatSimpleResponse formats a response that does not warrant additional explanation in the details section.

func FormatTestLabels added in v1.4.0

func FormatTestLabels(org, repo string, number int, labels ...string) []string

FormatTestLabels will prefix the label with org/repo#number.

Types

type AutoRespond

type AutoRespond struct {
	// Regex specifies the conditions for the trigger to respond automatically.
	Regex string `json:"regex,omitempty"`
	// Message specifies the content of the automatic respond.
	Message string `json:"message,omitempty"`
}

AutoRespond is the config for auto respond.

type BlockLabel added in v1.1.0

type BlockLabel struct {
	// Regex specifies the regular expression for match the labels that need to be intercepted.
	Regex string `json:"regex,omitempty"`
	// Actions specifies the label actions that will trigger interception, you can fill in `labeled` or `unlabelled`.
	Actions []string `json:"actions,omitempty"`
	// TrustedTeams specifies the teams allowed adding/removing label.
	TrustedTeams []string `json:"trusted_teams,omitempty"`
	// TrustedUsers specifies the github login of the account allowed adding/removing label.
	TrustedUsers []string `json:"trusted_users,omitempty"`
	// Message specifies the message feedback to the user after blocking the label.
	Message string `json:"message,omitempty"`
}

BlockLabel is the config for label blocking.

type ConfigAgent

type ConfigAgent struct {
	// contains filtered or unexported fields
}

ConfigAgent contains the agent mutex and the agent configuration.

func (*ConfigAgent) Config

func (pa *ConfigAgent) Config() *Configuration

Config returns the agent current Configuration.

func (*ConfigAgent) Load

func (pa *ConfigAgent) Load(path string) error

Load attempts to load config from the path. It returns an error if either the file can't be read or the configuration is invalid. If checkUnknownPlugins is true, unrecognized plugin names will make config loading fail.

func (*ConfigAgent) Set

func (pa *ConfigAgent) Set(pc *Configuration)

Set attempts to set the plugins config.

func (*ConfigAgent) Start

func (pa *ConfigAgent) Start(path string, checkUnknownPlugins bool) error

Start starts polling path for plugin config. If the first attempt fails, then start returns the error. Future errors will halt updates but not stop. If checkUnknownPlugins is true, unrecognized plugin names will make config loading fail.

type Configuration

type Configuration struct {
	TichiWebURL     string `json:"tichi_web_url,omitempty"`
	PRProcessLink   string `json:"pr_process_link,omitempty"`
	CommandHelpLink string `json:"command_help_link,omitempty"`

	// LogLevel enables dynamically updating the log level of the
	// standard logger that is used by all ti community plugin.
	//
	// Valid values:
	//
	// "trace" "debug", "info", "warn", "warning", "error", "fatal", "panic"
	//
	// Defaults to "info".
	LogLevel string `json:"log_level,omitempty"`

	TiCommunityLgtm          []TiCommunityLgtm          `json:"ti-community-lgtm,omitempty"`
	TiCommunityMerge         []TiCommunityMerge         `json:"ti-community-merge,omitempty"`
	TiCommunityOwners        []TiCommunityOwners        `json:"ti-community-owners,omitempty"`
	TiCommunityLabel         []TiCommunityLabel         `json:"ti-community-label,omitempty"`
	TiCommunityAutoresponder []TiCommunityAutoresponder `json:"ti-community-autoresponder,omitempty"`
	TiCommunityBlunderbuss   []TiCommunityBlunderbuss   `json:"ti-community-blunderbuss,omitempty"`
	TiCommunityTars          []TiCommunityTars          `json:"ti-community-tars,omitempty"`
	TiCommunityLabelBlocker  []TiCommunityLabelBlocker  `json:"ti-community-label-blocker,omitempty"`
	TiCommunityContribution  []TiCommunityContribution  `json:"ti-community-contribution,omitempty"`
	TiCommunityCherrypicker  []TiCommunityCherrypicker  `json:"ti-community-cherrypicker,omitempty"`
	TiCommunityFormatChecker []TiCommunityFormatChecker `json:"ti-community-format-checker,omitempty"`
}

Configuration is the top-level serialization target for external plugin Configuration.

func (*Configuration) AutoresponderFor

func (c *Configuration) AutoresponderFor(org, repo string) *TiCommunityAutoresponder

AutoresponderFor finds the TiCommunityAutoresponder for a repo, if one exists. TiCommunityAutoresponder configuration can be listed for a repository or an organization.

func (*Configuration) BlunderbussFor

func (c *Configuration) BlunderbussFor(org, repo string) *TiCommunityBlunderbuss

BlunderbussFor finds the TiCommunityBlunderbuss for a repo, if one exists. TiCommunityBlunderbuss configuration can be listed for a repository or an organization.

func (*Configuration) CherrypickerFor added in v1.5.0

func (c *Configuration) CherrypickerFor(org, repo string) *TiCommunityCherrypicker

CherrypickerFor finds the TiCommunityCherrypicker for a repo, if one exists. TiCommunityCherrypicker configuration can be listed for a repository or an organization.

func (*Configuration) ContributionFor added in v1.4.0

func (c *Configuration) ContributionFor(org, repo string) *TiCommunityContribution

ContributionFor finds the TiCommunityContribution for a repo, if one exists. TiCommunityContribution configuration can be listed for a repository or an organization.

func (*Configuration) FormatCheckerFor added in v1.9.0

func (c *Configuration) FormatCheckerFor(org, repo string) *TiCommunityFormatChecker

FormatCheckerFor finds the TiCommunityFormatChecker for a repo, if one exists. TiCommunityFormatChecker configuration can be listed for a repository or an organization.

func (*Configuration) LabelBlockerFor added in v1.1.0

func (c *Configuration) LabelBlockerFor(org, repo string) *TiCommunityLabelBlocker

LabelBlockerFor finds the TiCommunityLabelBlocker for a repo, if one exists. TiCommunityLabelBlocker configuration can be listed for a repository or an organization.

func (*Configuration) LabelFor

func (c *Configuration) LabelFor(org, repo string) *TiCommunityLabel

LabelFor finds the TiCommunityLabel for a repo, if one exists. TiCommunityLabel configuration can be listed for a repository or an organization.

func (*Configuration) LgtmFor

func (c *Configuration) LgtmFor(org, repo string) *TiCommunityLgtm

LgtmFor finds the Lgtm for a repo, if one exists a trigger can be listed for the repo itself or for the owning organization

func (*Configuration) MergeFor

func (c *Configuration) MergeFor(org, repo string) *TiCommunityMerge

MergeFor finds the TiCommunityMerge for a repo, if one exists. TiCommunityMerge configuration can be listed for a repository or an organization.

func (*Configuration) OwnersFor

func (c *Configuration) OwnersFor(org, repo string) *TiCommunityOwners

OwnersFor finds the TiCommunityOwners for a repo, if one exists. TiCommunityOwners configuration can be listed for a repository or an organization.

func (*Configuration) TarsFor

func (c *Configuration) TarsFor(org, repo string) *TiCommunityTars

TarsFor finds the TiCommunityTars for a repo, if one exists. TiCommunityTars configuration can be listed for a repository or an organization.

func (*Configuration) Validate

func (c *Configuration) Validate() error

Validate will return an error if there are any invalid external plugin config.

type EventType added in v1.3.4

type EventType = string

EventType is an alias of string which describe the GitHub webhook event.

const (
	IssuesEvent       EventType = "issues"
	IssueCommentEvent EventType = "issue_comment"

	PullRequestEvent              EventType = "pull_request"
	PullRequestReviewEvent        EventType = "pull_request_review"
	PullRequestReviewCommentEvent EventType = "pull_request_review_comment"

	PushEvent EventType = "push"

	StatusEvent EventType = "status"
)

Event type constants.

type RequiredMatchRule added in v1.9.0

type RequiredMatchRule struct {
	// PullRequest specifies whether check for pull request.
	PullRequest bool `json:"pull_request,omitempty"`
	// Issue specifies whether check for issue.
	Issue bool `json:"issue,omitempty"`
	// Title specifies whether check the issue or pull request title.
	Title bool `json:"title,omitempty"`
	// Body specifies whether check the issue or pull request body.
	Body bool `json:"body,omitempty"`
	// CommitMessage specifies whether check the message of commits in the pull request.
	CommitMessage bool `json:"commit_message,omitempty"`
	// Regexp specifies the regular expression used for text match.
	Regexp string `json:"regexp"`
	// MissingMessage specifies the content commented by bot when there is no match.
	MissingMessage string `json:"missing_message,omitempty"`
	// MissingLabel specifies the label added by the bot when there is no match.
	MissingLabel string `json:"missing_label,omitempty"`
	// SkipLabel specifies the label added by the contributor for skipping the format checking.
	SkipLabel string `json:"skip_label,omitempty"`
}

RequiredMatchRule is config about match rules for checking issue or PR content.

type TiCommunityAutoresponder

type TiCommunityAutoresponder struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// AutoResponds is a set of responds.
	AutoResponds []AutoRespond `json:"auto_responds,omitempty"`
}

TiCommunityAutoresponder is the config for the blunderbuss plugin.

type TiCommunityBlunderbuss

type TiCommunityBlunderbuss struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// MaxReviewerCount is the maximum number of reviewers to request
	// reviews from. Defaults to 0 meaning no limit.
	MaxReviewerCount int `json:"max_request_count,omitempty"`
	// IncludeReviewers specifies which reviewers are the only ones involved in the code review.
	IncludeReviewers []string `json:"include_reviewers,omitempty"`
	// ExcludeReviewers specifies which reviewers do not participate in code review.
	ExcludeReviewers []string `json:"exclude_reviewers,omitempty"`
	// PullOwnersEndpoint specifies the URL of the reviewer of pull request.
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
	// GracePeriodDuration specifies the waiting time before the plugin requests a review,
	// defaults to 5 means that the plugin will wait 5 seconds for the sig label to be added.
	GracePeriodDuration int `json:"grace_period_duration,omitempty"`
	// RequireSigLabel specifies whether the PR is required to have a sig label before requesting reviewers.
	RequireSigLabel bool `json:"require_sig_label,omitempty"`
}

TiCommunityBlunderbuss is the config for the blunderbuss plugin.

type TiCommunityCherrypicker added in v1.5.0

type TiCommunityCherrypicker struct {
	// Repos is either of the form org/repo or just org.
	Repos []string `json:"repos,omitempty"`
	// AllowAll specifies whether everyone is allowed to cherry pick.
	AllowAll bool `json:"allow_all,omitempty"`
	// IssueOnConflict specifies whether to create an Issue when there is a PR conflict.
	IssueOnConflict bool `json:"create_issue_on_conflict,omitempty"`
	// LabelPrefix specifies the label prefix for cherrypicker.
	LabelPrefix string `json:"label_prefix,omitempty"`
	// PickedLabelPrefix specifies the label prefix after picked.
	PickedLabelPrefix string `json:"picked_label_prefix,omitempty"`
	// ExcludeLabels specifies the labels that need to be excluded when copying the labels of the original PR.
	ExcludeLabels []string `json:"excludeLabels,omitempty"`
	// CopyIssueNumbersFromSquashedCommit specifies whether to copy the issue numbers from the squashed commit message.
	CopyIssueNumbersFromSquashedCommit bool `json:"copy_issue_numbers_from_squashed_commit"`
}

TiCommunityCherrypicker is the config for the cherrypicker plugin.

type TiCommunityContribution added in v1.4.0

type TiCommunityContribution struct {
	// Repos is either of the form org/repo or just org.
	Repos []string `json:"repos,omitempty"`
	// Message specifies the tips for the contributor's PR.
	Message string `json:"message,omitempty"`
}

TiCommunityContribution is the config for the contribution plugin.

type TiCommunityFormatChecker added in v1.9.0

type TiCommunityFormatChecker struct {
	// Repos are either of the form org/repo or just org.
	Repos []string `json:"repos,omitempty"`
	// RequiredMatchRules specifies rules required to match.
	RequiredMatchRules []RequiredMatchRule `json:"required_match_rules,omitempty"`
}

TiCommunityFormatChecker is the config for the format-checker plugin.

type TiCommunityLabel

type TiCommunityLabel struct {
	// Repos is either of the form org/repos or just org.
	// The AdditionalLabels and Prefixes values are applicable
	// to these repos.
	Repos []string `json:"repos,omitempty"`
	// AdditionalLabels is a set of additional labels enabled for use
	// on top of the existing "status/*", "priority/*"
	// and "sig/*" labels.
	// Labels can be used with `/[remove-]label <additionalLabel>` commands.
	AdditionalLabels []string `json:"additional_labels,omitempty"`
	// Prefixes is a set of label prefixes which replaces the existing
	// "status", "priority"," and "sig" label prefixes.
	// Labels can be used with `/[remove-]<prefix> <target>` commands.
	Prefixes []string `json:"prefixes,omitempty"`
	// ExcludeLabels specifies labels that cannot be added by TiCommunityLabel.
	ExcludeLabels []string `json:"exclude_labels,omitempty"`
}

TiCommunityLabel is the config for the label plugin.

type TiCommunityLabelBlocker added in v1.1.0

type TiCommunityLabelBlocker struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// BlockLabels is a set of label block rules.
	BlockLabels []BlockLabel `json:"block_labels,omitempty"`
}

TiCommunityLabelBlocker is the config for the label blocker plugin.

type TiCommunityLgtm

type TiCommunityLgtm struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// PullOwnersEndpoint specifies the URL of the reviewer of pull request.
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
	// IgnoreInvalidReviewPrompt specifies no prompt when review is invalid, default is `false`.
	IgnoreInvalidReviewPrompt bool `json:"ignore_invalid_review_prompt"`
}

TiCommunityLgtm specifies a configuration for a single ti community lgtm. The configuration for the ti community lgtm plugin is defined as a list of these structures.

type TiCommunityMerge

type TiCommunityMerge struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// StoreTreeHash indicates if tree_hash should be stored inside a comment to detect
	// guaranteed commits before removing can merge labels.
	StoreTreeHash bool `json:"store_tree_hash,omitempty"`
	// PullOwnersEndpoint specifies the URL of the reviewer of pull request.
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
}

TiCommunityMerge specifies a configuration for a single merge.

The configuration for the merge plugin is defined as a list of these structures.

type TiCommunityOwnerBranchConfig

type TiCommunityOwnerBranchConfig struct {
	// DefaultRequireLgtm specifies the default require lgtm number of the branch.
	DefaultRequireLgtm int `json:"default_require_lgtm,omitempty"`
	// ReviewerTeams specifies the GitHub teams whose members can review pull request.
	ReviewerTeams []string `json:"reviewer_teams,omitempty"`
	// CommitterTeams specifies the GitHub teams whose members can merge pull request.
	CommitterTeams []string `json:"committer_teams,omitempty"`
	// UseGitHubPermission specifies the permissions to use GitHub.
	// People with write and admin permissions have reviewer and committer permissions.
	UseGitHubPermission bool `json:"use_github_permission,omitempty"`
	// UseGithubTeam specifies the permissions to use specified GitHub team as committer teams or reviewer teams.
	UseGithubTeam bool `json:"use_github_team,omitempty"`
}

TiCommunityOwnerBranchConfig is the branch level configuration of the owners plugin.

type TiCommunityOwners

type TiCommunityOwners struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// SigEndpoint specifies the URL of the sig info.
	SigEndpoint string `json:"sig_endpoint,omitempty"`
	// DefaultSigName specifies the default sig name of this repo's PR.
	DefaultSigName string `json:"default_sig_name,omitempty"`
	// DefaultRequireLgtm specifies the default require lgtm number.
	DefaultRequireLgtm int `json:"default_require_lgtm,omitempty"`
	// RequireLgtmLabelPrefix specifies the prefix of require lgtm label.
	RequireLgtmLabelPrefix string `json:"require_lgtm_label_prefix,omitempty"`
	// ReviewerTeams specifies the GitHub teams whose members can review pull request.
	ReviewerTeams []string `json:"reviewer_teams,omitempty"`
	// CommitterTeams specifies the GitHub teams whose members can merge pull request.
	CommitterTeams []string `json:"committer_teams,omitempty"`
	// UseGitHubPermission specifies the permissions to use GitHub.
	// People with write and admin permissions have reviewer and committer permissions.
	UseGitHubPermission bool `json:"use_github_permission,omitempty"`
	// UseGithubTeam specifies the permissions to use specified GitHub team as committer teams or reviewer teams.
	UseGithubTeam bool `json:"use_github_team,omitempty"`
	// Branches specifies the branch level configuration that will override the repository
	// level configuration.
	Branches map[string]TiCommunityOwnerBranchConfig `json:"branches,omitempty"`
}

TiCommunityOwners specifies a configuration for a single ti community owners plugin.

The configuration for the owners plugin is defined as a list of these structures.

type TiCommunityTars

type TiCommunityTars struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// Message specifies the message when the PR is automatically updated.
	Message string `json:"message,omitempty"`
	// OnlyWhenLabel specifies that the automatic update is triggered only when the PR has this label.
	OnlyWhenLabel string `json:"only_when_label,omitempty"`
	// ExcludeLabels specifies that the automatic update are not triggered when the PR has these labels.
	ExcludeLabels []string `json:"exclude_labels,omitempty"`
}

TiCommunityTars is the config for the tars plugin.

Jump to

Keyboard shortcuts

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