func (c *Configuration) AutoresponderFor(org, repo string) *TiCommunityAutoresponder {
	fullName := fmt.Sprintf("%s/%s", org, repo)
	for _, autoresponder := range c.TiCommunityAutoresponder {
		if !sets.NewString(autoresponder.Repos...).Has(fullName) {
			continue
		}
		return &autoresponder
	}
	for _, autoresponder := range c.TiCommunityAutoresponder {
		if !sets.NewString(autoresponder.Repos...).Has(org) {
			continue
		}
		return &autoresponder
	}
	return &TiCommunityAutoresponder{}
}
AutoresponderFor finds the TiCommunityAutoresponder for a repo, if one exists.
TiCommunityAutoresponder configuration can be listed for a repository
or an organization.
package externalplugins
import (
	"errors"
	"fmt"
	"net/url"
	"regexp"
	"strings"
	"github.com/sirupsen/logrus"
	"k8s.io/apimachinery/pkg/util/sets"
	"k8s.io/test-infra/prow/labels"
)
const (
	defaultGracePeriodDuration = 5
	defaultLogLevel = logrus.InfoLevel
)
const (
	LabeledAction   = "labeled"
	UnlabeledAction = "unlabeled"
)
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 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"`
}
type TiCommunityLgtm struct {
	Repos []string `json:"repos,omitempty"`
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
}
type TiCommunityMerge struct {
	Repos []string `json:"repos,omitempty"`
	StoreTreeHash bool `json:"store_tree_hash,omitempty"`
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
}
type TiCommunityOwners struct {
	Repos []string `json:"repos,omitempty"`
	SigEndpoint string `json:"sig_endpoint,omitempty"`
	DefaultSigName string `json:"default_sig_name,omitempty"`
	DefaultRequireLgtm int `json:"default_require_lgtm,omitempty"`
	RequireLgtmLabelPrefix string `json:"require_lgtm_label_prefix,omitempty"`
	ReviewerTeams []string `json:"reviewer_teams,omitempty"`
	CommitterTeams []string `json:"committer_teams,omitempty"`
	UseGitHubPermission bool `json:"use_github_permission,omitempty"`
	UseGithubTeam bool `json:"use_github_team,omitempty"`
	Branches map[string]TiCommunityOwnerBranchConfig `json:"branches,omitempty"`
}
type TiCommunityOwnerBranchConfig struct {
	DefaultRequireLgtm int `json:"default_require_lgtm,omitempty"`
	ReviewerTeams []string `json:"reviewer_teams,omitempty"`
	CommitterTeams []string `json:"committer_teams,omitempty"`
	UseGitHubPermission bool `json:"use_github_permission,omitempty"`
	UseGithubTeam bool `json:"use_github_team,omitempty"`
}
type TiCommunityLabel struct {
	Repos []string `json:"repos,omitempty"`
	AdditionalLabels []string `json:"additional_labels,omitempty"`
	Prefixes []string `json:"prefixes,omitempty"`
	ExcludeLabels []string `json:"exclude_labels,omitempty"`
}
type TiCommunityAutoresponder struct {
	Repos []string `json:"repos,omitempty"`
	AutoResponds []AutoRespond `json:"auto_responds,omitempty"`
}
type AutoRespond struct {
	Regex string `json:"regex,omitempty"`
	Message string `json:"message,omitempty"`
}
type TiCommunityBlunderbuss struct {
	Repos []string `json:"repos,omitempty"`
	MaxReviewerCount int `json:"max_request_count,omitempty"`
	IncludeReviewers []string `json:"include_reviewers,omitempty"`
	ExcludeReviewers []string `json:"exclude_reviewers,omitempty"`
	PullOwnersEndpoint string `json:"pull_owners_endpoint,omitempty"`
	GracePeriodDuration int `json:"grace_period_duration,omitempty"`
	RequireSigLabel bool `json:"require_sig_label,omitempty"`
}
func (c *TiCommunityBlunderbuss) setDefaults() {
	if c.GracePeriodDuration == 0 {
		c.GracePeriodDuration = defaultGracePeriodDuration
	}
}
type TiCommunityTars struct {
	Repos []string `json:"repos,omitempty"`
	Message string `json:"message,omitempty"`
	OnlyWhenLabel string `json:"only_when_label,omitempty"`
	ExcludeLabels []string `json:"exclude_labels,omitempty"`
}
func (c *TiCommunityTars) setDefaults() {
	if len(c.OnlyWhenLabel) == 0 {
		c.OnlyWhenLabel = CanMergeLabel
	}
	if len(c.ExcludeLabels) == 0 {
		c.ExcludeLabels = append(c.ExcludeLabels, labels.NeedsRebase)
		c.ExcludeLabels = append(c.ExcludeLabels, labels.Hold)
		c.ExcludeLabels = append(c.ExcludeLabels, labels.WorkInProgress)
	}
}
type TiCommunityLabelBlocker struct {
	Repos []string `json:"repos,omitempty"`
	BlockLabels []BlockLabel `json:"block_labels,omitempty"`
}
type BlockLabel struct {
	Regex string `json:"regex,omitempty"`
	Actions []string `json:"actions,omitempty"`
	TrustedTeams []string `json:"trusted_teams,omitempty"`
	TrustedUsers []string `json:"trusted_users,omitempty"`
	Message string `json:"message,omitempty"`
}
type TiCommunityContribution struct {
	Repos []string `json:"repos,omitempty"`
	Message string `json:"message,omitempty"`
}
type TiCommunityCherrypicker struct {
	Repos []string `json:"repos,omitempty"`
	AllowAll bool `json:"allow_all,omitempty"`
	IssueOnConflict bool `json:"create_issue_on_conflict,omitempty"`
	LabelPrefix string `json:"label_prefix,omitempty"`
	PickedLabelPrefix string `json:"picked_label_prefix,omitempty"`
	ExcludeLabels []string `json:"excludeLabels,omitempty"`
}
func (c *TiCommunityCherrypicker) setDefaults() {
	if len(c.LabelPrefix) == 0 {
		c.LabelPrefix = DefaultCherryPickLabelPrefix
	}
}
type TiCommunityFormatChecker struct {
	Repos []string `json:"repos,omitempty"`
	RequiredMatchRules []RequiredMatchRule `json:"required_match_rules,omitempty"`
}
type RequiredMatchRule struct {
	PullRequest bool `json:"pull_request,omitempty"`
	Issue bool `json:"issue,omitempty"`
	Title bool `json:"title,omitempty"`
	Body bool `json:"body,omitempty"`
	CommitMessage bool `json:"commit_message,omitempty"`
	Regexp string `json:"regexp"`
	MissingMessage string `json:"missing_message,omitempty"`
	MissingLabel string `json:"missing_label,omitempty"`
}
func (c *Configuration) LgtmFor(org, repo string) *TiCommunityLgtm {
	fullName := fmt.Sprintf("%s/%s", org, repo)
	for _, lgtm := range c.TiCommunityLgtm {
		if !sets.NewString(lgtm.Repos...).Has(fullName) {
			continue
		}
		return &lgtm
	}
	for _, lgtm := range c.TiCommunityLgtm {
		if !sets.NewString(lgtm.Repos...).Has(org) {
			continue
		}
		return &lgtm
	}
	return &TiCommunityLgtm{}
}
func (c *Configuration) MergeFor(org, repo string) *TiCommunityMerge {
	fullName := fmt.Sprintf("%s/%s", org, repo)
	for _, merge := range c.TiCommunityMerge {
		if !sets.NewString(merge.Repos...).Has(fullName) {
			continue
		}
		return &merge
	}
	for _, merge := range c.TiCommunityMerge {
		if !sets.NewString(merge.Repos...).Has(org) {
			continue
		}
		return &merge
	}
	return &TiCommunityMerge{}
}
func (c *Configuration) OwnersFor(org, repo string) *TiCommunityOwners {
	fullName := fmt.Sprintf("%s/%s", org, repo)
	for _, owners := range c.TiCommunityOwners {
		if !sets.NewString(owners.Repos...).Has(fullName) {
			continue
		}
		return &owners
	}
	for _, owners := range c.TiCommunityOwners {
		if !sets.NewString(owners.Repos...).Has(org) {
			continue
		}
		return &owners
	}
	return &TiCommunityOwners{}
}
func (c *Configuration) LabelFor(org, repo string) *TiCommunityLabel {
	fullName := fmt.Sprintf("%s/%s", org, repo)
	for _, label := range c.TiCommunityLabel {
		if !sets.NewString(label.Repos...).Has(fullName) {
			continue
		}
		return &label
	}
	for _, label := range c.TiCommunityLabel {
		if !sets.NewString(label.Repos...).Has(org) {
			continue
		}
		return &label
	}
	return &TiCommunityLabel{}
}