externalplugins

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

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/"
)

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"
)

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.

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 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"`

	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"`
}

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) 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 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"`
	// 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 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 TiCommunityLgtm

type TiCommunityLgtm struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// ReviewActsAsLgtm indicates that a GitHub review of "merge" or "request changes"
	// acts as adding or removing the lgtm label.
	ReviewActsAsLgtm bool `json:"review_acts_as_lgtm,omitempty"`
	// PullOwnersEndpoint specifies the URL of the reviewer of pull request.
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
}

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"`
	// TrustTeams specifies the GitHub teams whose members are trusted by the branch.
	TrustTeams []string `json:"trusted_teams,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"`
	// WARNING: This disables the security mechanism that prevents a malicious member (or
	// compromised GitHub account) from merging arbitrary code. Use with caution.
	//
	// TrustTeams specifies the GitHub teams whose members are trusted.
	TrustTeams []string `json:"trusted_teams,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"`
}

TiCommunityTars is the config for the tars plugin.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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