plugins

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

README

prow plugins

Most plugins lack README's but instead provide PluginHelp structs during init

Please see https://prow.k8s.io/plugins for a list of all deployed plugins, what they do, and what commands they offer

For an alternate view, please see https://prow.k8s.io/command-help to see all of the commands offered by the deployed plugins

Documentation

Index

Constants

View Source
const AboutThisBotCommands = "I understand the commands that are listed [here](https://go.k8s.io/bot-commands)."
View Source
const AboutThisBotWithoutCommands = "" /* 346-byte string literal not displayed */

Variables

This section is empty.

Functions

func EventsForPlugin

func EventsForPlugin(name string) []string

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 HelpProviders

func HelpProviders() map[string]HelpProvider

func RegisterGenericCommentHandler

func RegisterGenericCommentHandler(name string, fn GenericCommentHandler, help HelpProvider)

func RegisterIssueCommentHandler

func RegisterIssueCommentHandler(name string, fn IssueCommentHandler, help HelpProvider)

func RegisterIssueHandler

func RegisterIssueHandler(name string, fn IssueHandler, help HelpProvider)

func RegisterPullRequestHandler

func RegisterPullRequestHandler(name string, fn PullRequestHandler, help HelpProvider)

func RegisterPushEventHandler

func RegisterPushEventHandler(name string, fn PushEventHandler, help HelpProvider)

func RegisterReviewCommentEventHandler

func RegisterReviewCommentEventHandler(name string, fn ReviewCommentEventHandler, help HelpProvider)

func RegisterReviewEventHandler

func RegisterReviewEventHandler(name string, fn ReviewEventHandler, help HelpProvider)

func RegisterStatusEventHandler

func RegisterStatusEventHandler(name string, fn StatusEventHandler, help HelpProvider)

Types

type Approve

type Approve struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// IssueRequired indicates if an associated issue is required for approval in
	// the specified repos.
	IssueRequired bool `json:"issue_required,omitempty"`
	// ImplicitSelfApprove indicates if authors implicitly approve their own PRs
	// in the specified repos.
	ImplicitSelfApprove bool `json:"implicit_self_approve,omitempty"`
	// LgtmActsAsApprove indicates that the lgtm command should be used to
	// indicate approval
	LgtmActsAsApprove bool `json:"lgtm_acts_as_approve,omitempty"`
	// ReviewActsAsApprove indicates that GitHub review state should be used to
	// indicate approval.
	ReviewActsAsApprove bool `json:"review_acts_as_approve,omitempty"`
}

type Blockade

type Blockade struct {
	// Repos are either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// BlockRegexps are regular expressions matching the file paths to block.
	BlockRegexps []string `json:"blockregexps,omitempty"`
	// ExceptionRegexps are regular expressions matching the file paths that are exceptions to the BlockRegexps.
	ExceptionRegexps []string `json:"exceptionregexps,omitempty"`
	// Explanation is a string that will be included in the comment left when blocking a PR. This should
	// be an explanation of why the paths specified are blockaded.
	Explanation string `json:"explanation,omitempty"`
}
  Blockade specifies a configuration for a single blockade.blockade. The configuration for the
  blockade plugin is defined as a list of these structures. Here is an example of a complete
  yaml config for the blockade plugin that is composed of 2 Blockade structs:

	blockades:
	- repos:
	  - kubernetes-incubator
	  - kubernetes/kubernetes
	  - kubernetes/test-infra
	  blockregexps:
	  - 'docs/.*'
	  - 'other-docs/.*'
	  exceptionregexps:
	  - '.*OWNERS'
	  explanation: "Files in the 'docs' directory should not be modified except for OWNERS files"
	- repos:
	  - kubernetes/test-infra
	  blockregexps:
	  - 'mungegithub/.*'
	  exceptionregexps:
	  - 'mungegithub/DeprecationWarning.md'
	  explanation: "Don't work on mungegithub! Work on Prow!"

type Blunderbuss

type Blunderbuss struct {
	// ReviewerCount is the minimum number of reviewers to request
	// reviews from. Defaults to requesting reviews from 2 reviewers
	// if FileWeightCount is not set.
	ReviewerCount *int `json:"request_count,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"`
	// FileWeightCount is the maximum number of reviewers to request
	// reviews from. Selects reviewers based on file weighting.
	// This and request_count are mutually exclusive options.
	FileWeightCount *int `json:"file_weight_count,omitempty"`
	// ExcludeApprovers controls whether approvers are considered to be
	// reviewers. By default, approvers are considered as reviewers if
	// insufficient reviewers are available. If ExcludeApprovers is true,
	// approvers will never be considered as reviewers.
	ExcludeApprovers bool `json:"exclude_approvers,omitempty"`
}

type Cat

type Cat struct {
	// Path to file containing an api key for thecatapi.com
	KeyPath string `json:"key_path,omitempty"`
}

type ConfigMapSpec

type ConfigMapSpec struct {
	// Name of ConfigMap
	Name string `json:"name"`
	// Key is the key in the ConfigMap to update with the file contents.
	// If no explicit key is given, the basename of the file will be used.
	Key string `json:"key,omitempty"`
	// Namespace in which the configMap needs to be deployed. If no namespace is specified
	// it will be deployed to the ProwJobNamespace.
	Namespace string `json:"namespace,omitempty"`
}

ConfigMapSpec contains configuration options for the configMap being updated by the ConfigUpdater plugin

type ConfigUpdater

type ConfigUpdater struct {
	// A map of filename => ConfigMapSpec.
	// Whenever a commit changes filename, prow will update the corresponding configmap.
	// map[string]ConfigMapSpec{ "/my/path.yaml": {Name: "foo", Namespace: "otherNamespace" }}
	// will result in replacing the foo configmap whenever path.yaml changes
	Maps map[string]ConfigMapSpec `json:"maps,omitempty"`
	// The location of the prow configuration file inside the repository
	// where the config-updater plugin is enabled. This needs to be relative
	// to the root of the repository, eg. "prow/config.yaml" will match
	// github.com/kubernetes/test-infra/prow/config.yaml assuming the config-updater
	// plugin is enabled for kubernetes/test-infra. Defaults to "prow/config.yaml".
	ConfigFile string `json:"config_file,omitempty"`
	// The location of the prow plugin configuration file inside the repository
	// where the config-updater plugin is enabled. This needs to be relative
	// to the root of the repository, eg. "prow/plugins.yaml" will match
	// github.com/kubernetes/test-infra/prow/plugins.yaml assuming the config-updater
	// plugin is enabled for kubernetes/test-infra. Defaults to "prow/plugins.yaml".
	PluginFile string `json:"plugin_file,omitempty"`
}

type Configuration

type Configuration struct {
	// Plugins is a map of repositories (eg "k/k") to lists of
	// plugin names.
	// TODO: Link to the list of supported plugins.
	// https://github.com/kubernetes/test-infra/issues/3476
	Plugins map[string][]string `json:"plugins,omitempty"`

	// ExternalPlugins is a map of repositories (eg "k/k") to lists of
	// external plugins.
	ExternalPlugins map[string][]ExternalPlugin `json:"external_plugins,omitempty"`

	// Owners contains configuration related to handling OWNERS files.
	Owners Owners `json:"owners,omitempty"`

	// Built-in plugins specific configuration.
	Triggers      []Trigger            `json:"triggers,omitempty"`
	Heart         Heart                `json:"heart,omitempty"`
	RepoMilestone map[string]Milestone `json:"repo_milestone,omitempty"`
	Slack         Slack                `json:"slack,omitempty"`
	ConfigUpdater ConfigUpdater        `json:"config_updater,omitempty"`
	Blockades     []Blockade           `json:"blockades,omitempty"`
	Approve       []Approve            `json:"approve,omitempty"`
	Blunderbuss   Blunderbuss          `json:"blunderbuss,omitempty"`
	RequireSIG    RequireSIG           `json:"requiresig,omitempty"`
	SigMention    SigMention           `json:"sigmention,omitempty"`
	Cat           Cat                  `json:"cat,omitempty"`
	Label         *Label               `json:"label,omitempty"`
	Lgtm          []Lgtm               `json:"lgtm,omitempty"`
	Welcome       Welcome              `json:"welcome,omitempty"`
}

Configuration is the top-level serialization target for plugin Configuration

func (*Configuration) EnabledReposForExternalPlugin

func (c *Configuration) EnabledReposForExternalPlugin(plugin string) (orgs, repos []string)

func (*Configuration) EnabledReposForPlugin

func (c *Configuration) EnabledReposForPlugin(plugin string) (orgs, repos []string)

func (*Configuration) TriggerFor

func (c *Configuration) TriggerFor(org, repo string) *Trigger

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

type ExternalPlugin

type ExternalPlugin struct {
	// Name of the plugin.
	Name string `json:"name"`
	// Endpoint is the location of the external plugin. Defaults to
	// the name of the plugin, ie. "http://{{name}}".
	Endpoint string `json:"endpoint,omitempty"`
	// Events are the events that need to be demuxed by the hook
	// server to the external plugin. If no events are specified,
	// everything is sent.
	Events []string `json:"events,omitempty"`
}

ExternalPlugin holds configuration for registering an external plugin in prow.

type GenericCommentHandler

type GenericCommentHandler func(PluginClient, github.GenericCommentEvent) error

type Heart

type Heart struct {
	// Adorees is a list of GitHub logins for members
	// for whom we will add emojis to comments
	Adorees []string `json:"adorees,omitempty"`
}

type HelpProvider

type HelpProvider func(config *Configuration, enabledRepos []string) (*pluginhelp.PluginHelp, error)

type IssueCommentHandler

type IssueCommentHandler func(PluginClient, github.IssueCommentEvent) error

type IssueHandler

type IssueHandler func(PluginClient, github.IssueEvent) error

type Label

type Label struct {
	// AdditionalLabels is a set of additional labels enabled for use
	// on top of the existing "kind/*", "priority/*", and "area/*" labels.
	AdditionalLabels []string `json:"additional_labels"`
}

type Lgtm

type Lgtm struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// ReviewActsAsLgtm indicates that a Github review of "approve" or "request changes"
	// acts as adding or removing the lgtm label
	ReviewActsAsLgtm bool `json:"review_acts_as_lgtm,omitempty"`
}

type MergeWarning

type MergeWarning struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// List of channels on which a event is published.
	Channels []string `json:"channels,omitempty"`
	// A slack event is published if the user is not part of the WhiteList.
	WhiteList []string `json:"whitelist,omitempty"`
	// A slack event is published if the user is not on the branch whitelist
	BranchWhiteList map[string][]string `json:"branch_whitelist,omitempty"`
}

MergeWarning is a config for the slackevents plugin's manual merge warings. If a PR is pushed to any of the repos listed in the config then send messages to the all the slack channels listed if pusher is NOT in the whitelist.

type Milestone

type Milestone struct {
	// ID of the github team for the milestone maintainers (used for setting status labels)
	// You can curl the following endpoint in order to determine the github ID of your team
	// responsible for maintaining the milestones:
	// curl -H "Authorization: token <token>" https://api.github.com/orgs/<org-name>/teams
	MaintainersID   int    `json:"maintainers_id,omitempty"`
	MaintainersTeam string `json:"maintainers_team,omitempty"`
}

Milestone contains the configuration options for the milestone and milestonestatus plugins.

type Owners

type Owners struct {
	// MDYAMLRepos is a list of org and org/repo strings specifying the repos that support YAML
	// OWNERS config headers at the top of markdown (*.md) files. These headers function just like
	// the config in an OWNERS file, but only apply to the file itself instead of the entire
	// directory and all sub-directories.
	// The yaml header must be at the start of the file and be bracketed with "---" like so:
	/*
		---
		approvers:
		- mikedanese
		- thockin

		---
	*/
	MDYAMLRepos []string `json:"mdyamlrepos,omitempty"`

	// SkipCollaborators disables collaborator cross-checks and forces both
	// the approve and lgtm plugins to use solely OWNERS files for access
	// control in the provided repos.
	SkipCollaborators []string `json:"skip_collaborators,omitempty"`

	// LabelsBlackList holds a list of labels that should not be present in any
	// OWNERS file, preventing their automatic addition by the owners-label plugin.
	// This check is performed by the verify-owners plugin.
	LabelsBlackList []string `json:"labels_blacklist,omitempty"`
}

Owners contains configuration related to handling OWNERS files.

type PluginAgent

type PluginAgent struct {
	PluginClient
	// contains filtered or unexported fields
}

func (*PluginAgent) Config

func (pa *PluginAgent) Config() *Configuration

func (*PluginAgent) GenericCommentHandlers

func (pa *PluginAgent) GenericCommentHandlers(owner, repo string) map[string]GenericCommentHandler

GenericCommentHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) IssueCommentHandlers

func (pa *PluginAgent) IssueCommentHandlers(owner, repo string) map[string]IssueCommentHandler

IssueCommentHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) IssueHandlers

func (pa *PluginAgent) IssueHandlers(owner, repo string) map[string]IssueHandler

IssueHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) Load

func (pa *PluginAgent) 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 it contains an unknown plugin.

func (*PluginAgent) MDYAMLEnabled

func (pa *PluginAgent) MDYAMLEnabled(org, repo string) bool

func (*PluginAgent) PullRequestHandlers

func (pa *PluginAgent) PullRequestHandlers(owner, repo string) map[string]PullRequestHandler

PullRequestHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) PushEventHandlers

func (pa *PluginAgent) PushEventHandlers(owner, repo string) map[string]PushEventHandler

PushEventHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) ReviewCommentEventHandlers

func (pa *PluginAgent) ReviewCommentEventHandlers(owner, repo string) map[string]ReviewCommentEventHandler

ReviewCommentEventHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) ReviewEventHandlers

func (pa *PluginAgent) ReviewEventHandlers(owner, repo string) map[string]ReviewEventHandler

ReviewEventHandlers returns a map of plugin names to handlers for the repo.

func (*PluginAgent) Set

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

Set attempts to set the plugins that are enabled on repos. Plugins are listed as a map from repositories to the list of plugins that are enabled on them. Specifying simply an org name will also work, and will enable the plugin on all repos in the org.

func (*PluginAgent) SkipCollaborators

func (pa *PluginAgent) SkipCollaborators(org, repo string) bool

func (*PluginAgent) Start

func (pa *PluginAgent) Start(path string) 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.

func (*PluginAgent) StatusEventHandlers

func (pa *PluginAgent) StatusEventHandlers(owner, repo string) map[string]StatusEventHandler

StatusEventHandlers returns a map of plugin names to handlers for the repo.

type PluginClient

type PluginClient struct {
	GitHubClient *github.Client
	KubeClient   *kube.Client
	GitClient    *git.Client
	SlackClient  *slack.Client
	OwnersClient repoowners.Interface

	CommentPruner *commentpruner.EventClient

	// Config provides information about the jobs
	// that we know how to run for repos.
	Config *config.Config
	// PluginConfig provides plugin-specific options
	PluginConfig *Configuration

	Logger *logrus.Entry
}

PluginClient may be used concurrently, so each entry must be thread-safe.

type PullRequestHandler

type PullRequestHandler func(PluginClient, github.PullRequestEvent) error

type PushEventHandler

type PushEventHandler func(PluginClient, github.PushEvent) error

type RequireSIG

type RequireSIG struct {
	// GroupListURL is the URL where a list of the available SIGs can be found.
	GroupListURL string `json:"group_list_url,omitempty"`
}

RequireSIG specifies configuration for the require-sig plugin.

type ReviewCommentEventHandler

type ReviewCommentEventHandler func(PluginClient, github.ReviewCommentEvent) error

type ReviewEventHandler

type ReviewEventHandler func(PluginClient, github.ReviewEvent) error

type SigMention

type SigMention struct {
	// Regexp parses comments and should return matches to team mentions.
	// These mentions enable labeling issues or PRs with sig/team labels.
	// Furthermore, teams with the following suffixes will be mapped to
	// kind/* labels:
	//
	// * @org/team-bugs             --maps to--> kind/bug
	// * @org/team-feature-requests --maps to--> kind/feature
	// * @org/team-api-reviews      --maps to--> kind/api-change
	// * @org/team-proposals        --maps to--> kind/design
	//
	// Note that you need to make sure your regexp covers the above
	// mentions if you want to use the extra labeling. Defaults to:
	// (?m)@kubernetes/sig-([\w-]*)-(misc|test-failures|bugs|feature-requests|proposals|pr-reviews|api-reviews)
	//
	// Compiles into Re during config load.
	Regexp string         `json:"regexp,omitempty"`
	Re     *regexp.Regexp `json:"-"`
}

SigMention specifies configuration for the sigmention plugin.

type Slack

type Slack struct {
	MentionChannels []string       `json:"mentionchannels,omitempty"`
	MergeWarnings   []MergeWarning `json:"mergewarnings,omitempty"`
}

type StatusEventHandler

type StatusEventHandler func(PluginClient, github.StatusEvent) error

type Trigger

type Trigger struct {
	// Repos is either of the form org/repos or just org.
	Repos []string `json:"repos,omitempty"`
	// TrustedOrg is the org whose members' PRs will be automatically built
	// for PRs to the above repos. The default is the PR's org.
	TrustedOrg string `json:"trusted_org,omitempty"`
	// JoinOrgURL is a link that redirects users to a location where they
	// should be able to read more about joining the organization in order
	// to become trusted members. Defaults to the Github link of TrustedOrg.
	JoinOrgURL string `json:"join_org_url,omitempty"`
	// OnlyOrgMembers requires PRs and/or /ok-to-test comments to come from org members.
	// By default, trigger also include repo collaborators.
	OnlyOrgMembers bool `json:"only_org_members,omitempty"`
}

type Welcome

type Welcome struct {
	// MessageTemplate is the welcome message template to post on new-contributor PRs
	// For the info struct see prow/plugins/welcome/welcome.go's PRInfo
	// TODO(bentheelder): make this be configurable per-repo?
	MessageTemplate string `json:"message_template,omitempty"`
}

Welcome is config for the welcome plugin

Directories

Path Synopsis
Package blockade defines a plugin that adds the 'do-not-merge/blocked-paths' label to PRs that modify protected file paths.
Package blockade defines a plugin that adds the 'do-not-merge/blocked-paths' label to PRs that modify protected file paths.
buildifier defines a Prow plugin that runs buildifier over modified BUILD, WORKSPACE, and skylark (.bzl) files in pull requests.
buildifier defines a Prow plugin that runs buildifier over modified BUILD, WORKSPACE, and skylark (.bzl) files in pull requests.
Package cat adds cat images to issues in response to a /meow comment
Package cat adds cat images to issues in response to a /meow comment
Package docsnoretest contains a Prow plugin which manages a label indicating whether a given pull requests only changes documentation.
Package docsnoretest contains a Prow plugin which manages a label indicating whether a given pull requests only changes documentation.
Package dog adds dog images to issues in response to a /woof comment
Package dog adds dog images to issues in response to a /woof comment
Package hold contains a plugin which will allow users to label their own pull requests as not ready or ready for merge.
Package hold contains a plugin which will allow users to label their own pull requests as not ready or ready for merge.
Package setmilestone implements the `/milestone` command which allows members of the milestone maintainers team to specify a milestone to be applied to an Issue or PR.
Package setmilestone implements the `/milestone` command which allows members of the milestone maintainers team to specify a milestone to be applied to an Issue or PR.
Package milestonestatus implements the `/status` command which allows members of the milestone maintainers team to specify a `status/*` label to be applied to an Issue or PR.
Package milestonestatus implements the `/status` command which allows members of the milestone maintainers team to specify a `status/*` label to be applied to an Issue or PR.
Package override supports the /override context command.
Package override supports the /override context command.
Package sigmention recognize SIG '@' mentions and adds 'sig/*' and 'kind/*' labels as appropriate.
Package sigmention recognize SIG '@' mentions and adds 'sig/*' and 'kind/*' labels as appropriate.
Package size contains a Prow plugin which counts the number of lines changed in a pull request, buckets this number into a few size classes (S, L, XL, etc), and finally labels the pull request with this size.
Package size contains a Prow plugin which counts the number of lines changed in a pull request, buckets this number into a few size classes (S, L, XL, etc), and finally labels the pull request with this size.
Package skip implements the `/skip` command which allows users to clean up commit statuses of non-blocking presubmits on PRs.
Package skip implements the `/skip` command which allows users to clean up commit statuses of non-blocking presubmits on PRs.
Package stage defines a Prow plugin that defines the stage of the issue in the features process.
Package stage defines a Prow plugin that defines the stage of the issue in the features process.
Package welcome implements a prow plugin to welcome new contributors
Package welcome implements a prow plugin to welcome new contributors
Package wip will label a PR a work-in-progress if the author provides a prefix to their pull request title to the same effect.
Package wip will label a PR a work-in-progress if the author provides a prefix to their pull request title to the same effect.

Jump to

Keyboard shortcuts

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