Documentation ¶
Index ¶
- Constants
- Variables
- func GetLogFileLocation(fileLocation string) string
- func NewBool(b bool) *bool
- func NewInt(n int) *int
- func NewInt32(n int32) *int32
- func NewInt64(n int64) *int64
- func NewString(s string) *string
- func PingEventFromJSON(data io.Reader) *github.PingEvent
- func SetupLogging(config *Config) error
- type BuildMobileAppJob
- type Builds
- type ChecksService
- type Config
- type EETriggerInfo
- type EventData
- type GitService
- type GithubClient
- type Integration
- type IssuesService
- type JenkinsCredentials
- type LabelResponse
- type MetricsProvider
- type MetricsTransport
- type MockedBuilds
- type OrganizationsService
- type Payload
- type PipelineItem
- type PipelineTriggeredResponse
- type PipelineWorkflowResponse
- type PullRequestEvent
- type PullRequestsService
- type RateLimitTransport
- type RepositoriesService
- type Repository
- type Server
- func (s *Server) AutoMergePR() error
- func (s *Server) CheckPRActivity()
- func (s *Server) CheckTestServerLifeTime()
- func (s *Server) CleanOutdatedPRs()
- func (s *Server) CleanUpLabels(pr *model.PullRequest)
- func (s *Server) GetAwsConfig() *aws.Config
- func (s *Server) GetIssueFromGithub(ctx context.Context, ghIssue *github.Issue) (*model.Issue, error)
- func (s *Server) GetPullRequestFromGithub(ctx context.Context, pullRequest *github.PullRequest) (*model.PullRequest, error)
- func (s *Server) GetUpdateChecks(ctx context.Context, owner, repoName string, prNumber int) (*model.PullRequest, error)
- func (s *Server) IsBotUserFromCLAExclusionsList(user string) bool
- func (s *Server) IsOrgMember(user string) bool
- func (s *Server) RefreshMembers()
- func (s *Server) Start()
- func (s *Server) Stop() error
- func (s *Server) Tick()
- type WebhookValidationError
Constants ¶
const ( MsgCommenterPermission = "Looks like you don't have permissions to trigger this command.\n Only available for the PR submitter and org members" MsgOrganizationPermission = "We don't have permissions to update this PR, please contact the submitter to apply the update." MsgUpdatePullRequest = "Error trying to update the PR.\nPlease do it manually." )
Variables ¶
Functions ¶
func GetLogFileLocation ¶
func SetupLogging ¶
Types ¶
type BuildMobileAppJob ¶
type Builds ¶
type Builds struct{}
Builds implements buildsInterface for working with external CI/CD systems.
type ChecksService ¶
type ChecksService interface {
ListCheckRunsForRef(ctx context.Context, owner, repo, ref string, opts *github.ListCheckRunsOptions) (*github.ListCheckRunsResults, *github.Response, error)
}
type Config ¶
type Config struct { ListenAddress string MattermodURL string GithubAccessToken string GitHubTokenReserve int GithubUsername string GithubAccessTokenCherryPick string GitHubWebhookSecret string Org string Username string AutoAssignerTeam string AutoAssignerTeamID int64 CircleCIToken string TickRateMinutes int SpinmintExpirationHour int DriverName string DataSource string Repositories []*Repository BlockPRMergeLabels []string AutoPRMergeLabel string SetupSpinmintTag string SetupSpinmintMessage string SetupSpinmintDoneMessage string SetupSpinmintFailedMessage string DestroyedSpinmintMessage string DestroyedExpirationSpinmintMessage string SpinmintsUseHTTPS bool SetupSpinmintUpgradeTag string SetupSpinmintUpgradeMessage string SetupSpinmintUpgradeDoneMessage string BuildMobileAppTag string BuildMobileAppInitMessage string BuildMobileAppDoneMessage string BuildMobileAppFailedMessage string BuildMobileAppBranchPrefix string BuildMobileAppJobs []*BuildMobileAppJob EnterpriseReponame string EnterpriseTriggerReponame string EnterpriseWebappReponame string EnterpriseTriggerLabel string EnterpriseGithubStatusContext string EnterpriseGithubStatusTETests string EnterpriseGithubStatusEETests string EnterpriseWorkflowName string TranslationsMattermostWebhookURL string TranslationsMattermostMessage string TranslationsBot string StartLoadtestTag string StartLoadtestMessage string CLAExclusionsList []string CLAGithubStatusContext string SignedCLAURL string NeedsToSignCLAMessage string PrLabels []LabelResponse IssueLabels []LabelResponse IssueLabelsToCleanUp []string JenkinsCredentials map[string]*JenkinsCredentials DockerRegistryURL string DockerUsername string DockerPassword string BlacklistPaths []string AWSCredentials struct { ID string Secret string Token string } AWSRegion string AWSImageID string AWSKeyName string AWSInstanceType string AWSHostedZoneID string AWSSecurityGroup string AWSDnsSuffix string AWSSubNetID string MattermostWebhookURL string LogSettings struct { EnableConsole bool ConsoleJSON bool ConsoleLevel string EnableFile bool FileJSON bool FileLevel string FileLocation string AdvancedLogging mlog.LogTargetCfg } DaysUntilStale int ExemptStaleLabels []string StaleLabel string StaleComment string MetricsServerPort string }
type EETriggerInfo ¶
type EventData ¶
type EventData struct { Action string `json:"action"` Comment *github.PullRequestComment `json:"comment"` Issue *github.Issue `json:"issue"` Repository *github.Repository `json:"repository"` }
func EventDataFromJSON ¶
func (*EventData) HasAutoAssign ¶
HasAutoAssign is true if body contains "/autoassign"
func (*EventData) HasCheckCLA ¶
HasCheckCLA is true if body contains "/check-cla"
func (*EventData) HasCherryPick ¶
HasCherryPick is true if body contains "/cherry-pick"
func (*EventData) HasUpdateBranch ¶
HasUpdateBranch is true if body contains "/update-branch"
type GitService ¶
type GitService interface { CreateRef(ctx context.Context, owner string, repo string, ref *github.Reference) (*github.Reference, *github.Response, error) DeleteRef(ctx context.Context, owner string, repo string, ref string) (*github.Response, error) GetRef(ctx context.Context, owner string, repo string, ref string) (*github.Reference, *github.Response, error) }
type GithubClient ¶
type GithubClient struct { Checks ChecksService Git GitService Issues IssuesService Organizations OrganizationsService PullRequests PullRequestsService Repositories RepositoriesService // contains filtered or unexported fields }
GithubClient wraps the github.Client with relevant interfaces.
func NewGithubClient ¶
func NewGithubClient(accessToken string, limitTokens int, metrics MetricsProvider) (*GithubClient, error)
NewGithubClient returns a new Github client that will use a fixed 10 req/sec / 10 burst tokens rate limiter configuration
func NewGithubClientWithLimiter ¶
func NewGithubClientWithLimiter(accessToken string, limit rate.Limit, burstTokens int, metricsProvider MetricsProvider) *GithubClient
NewGithubClientWithLimiter returns a new Github client with the provided limit and burst tokens that will be used by the rate limit transport.
func (*GithubClient) RateLimits ¶
func (c *GithubClient) RateLimits(ctx context.Context) (*github.RateLimits, *github.Response, error)
type Integration ¶
type IssuesService ¶
type IssuesService interface { AddAssignees(ctx context.Context, owner, repo string, number int, assignees []string) (*github.Issue, *github.Response, error) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error) CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*github.Response, error) Edit(ctx context.Context, owner string, repo string, number int, issue *github.IssueRequest) (*github.Issue, *github.Response, error) Get(ctx context.Context, owner string, repo string, number int) (*github.Issue, *github.Response, error) ListByRepo(ctx context.Context, owner string, repo string, opts *github.IssueListByRepoOptions) ([]*github.Issue, *github.Response, error) ListComments(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error) ListLabelsByIssue(ctx context.Context, owner string, repo string, number int, opt *github.ListOptions) ([]*github.Label, *github.Response, error) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*github.Response, error) }
type JenkinsCredentials ¶
type LabelResponse ¶
type MetricsProvider ¶
type MetricsProvider interface { // ObserverHTTPRequestDuration stores the elapsed time for an HTTP request ObserveHTTPRequestDuration(method, handler, statusCode string, elapsed float64) // IncreaseWebhookRequest increases the counter for the webhook requests // identified by name IncreaseWebhookRequest(name string) // IncreaseWebhookErrors stores the number of errors identified by name IncreaseWebhookErrors(name string) // ObserveGithubRequestDuration stores the elapsed time for github requests ObserveGithubRequestDuration(method, handler, statusCode string, elapsed float64) // IncreaseGithubCacheHits stores the number of cache hits when a github request // is done. The information is stored using the HTTP method and the request handler IncreaseGithubCacheHits(method, handler string) // IncreaseGithubCacheMisses stores the number of cache misses when a github request // is done. The information is stored using the HTTP method and the request handler IncreaseGithubCacheMisses(method, handler string) // ObserverCronTaskDuration stores the elapsed time for a cron task ObserveCronTaskDuration(name string, elapsed float64) // IncreaseCronTaskErrors stores the number of errors for a cron task IncreaseCronTaskErrors(name string) }
MetricsProvider is the interface that exposes the communication with the metrics system this interface should be implemented by the different providers we want to include
type MetricsTransport ¶
type MetricsTransport struct { Base http.RoundTripper // contains filtered or unexported fields }
Transport is an HTTP transport that would check the requests and increase some metrics, cache errors, etc based on the requests and responses
func NewMetricsTransport ¶
func NewMetricsTransport(base http.RoundTripper, metrics MetricsProvider) *MetricsTransport
NewTransport returns a transport using a provided http.RoundTripper as the base and a metrics provider
func (*MetricsTransport) Client ¶
func (t *MetricsTransport) Client() *http.Client
Client returns a new http.Client using Transport as the default transport
type MockedBuilds ¶
type MockedBuilds struct {
Version string
}
MockedBuilds implements buildsInterface but returns hardcoded information. This is used for local development and/or testing.
type OrganizationsService ¶
type OrganizationsService interface { GetOrgMembership(ctx context.Context, user, org string) (*github.Membership, *github.Response, error) IsMember(ctx context.Context, org, user string) (bool, *github.Response, error) ListMembers(ctx context.Context, org string, opts *github.ListMembersOptions) ([]*github.User, *github.Response, error) }
type PipelineItem ¶
type PipelineItem struct { StoppedAt time.Time `json:"stopped_at"` Number int `json:"pipeline_number"` Status string `json:"status"` WorkflowID string `json:"id"` Name string `json:"name"` ProjectSlug string `json:"project_slug"` CreatedAt time.Time `json:"created_at"` ID string `json:"pipeline_id"` }
type PipelineWorkflowResponse ¶
type PipelineWorkflowResponse struct { Pipelines []PipelineItem `json:"items"` NextPageToken string `json:"next_page_token"` }
type PullRequestEvent ¶
type PullRequestEvent struct { Action string `json:"action"` PRNumber int `json:"number"` PullRequest *github.PullRequest `json:"pull_request"` Issue *github.Issue `json:"issue"` Label *github.Label `json:"label"` Repo *github.Repository `json:"repository"` RepositoryURL string `json:"repository_url"` }
func PullRequestEventFromJSON ¶
func PullRequestEventFromJSON(data io.Reader) (*PullRequestEvent, error)
type PullRequestsService ¶
type PullRequestsService interface { Get(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error) List(ctx context.Context, owner string, repo string, opts *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error) ListFiles(ctx context.Context, owner string, repo string, number int, opts *github.ListOptions) ([]*github.CommitFile, *github.Response, error) ListReviewers(ctx context.Context, owner, repo string, number int, opts *github.ListOptions) (*github.Reviewers, *github.Response, error) ListReviews(ctx context.Context, owner, repo string, number int, opts *github.ListOptions) ([]*github.PullRequestReview, *github.Response, error) Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *github.PullRequestOptions) (*github.PullRequestMergeResult, *github.Response, error) RequestReviewers(ctx context.Context, owner, repo string, number int, reviewers github.ReviewersRequest) (*github.PullRequest, *github.Response, error) UpdateBranch(ctx context.Context, owner, repo string, number int, opts *github.PullRequestBranchUpdateOptions) (*github.PullRequestBranchUpdateResponse, *github.Response, error) }
type RateLimitTransport ¶
type RateLimitTransport struct {
// contains filtered or unexported fields
}
RateLimitTransport will provide a layer based on http.RounTripper interface that provided rate limiting capability
func NewRateLimitTransport ¶
func NewRateLimitTransport(limit rate.Limit, tokens int, base http.RoundTripper) *RateLimitTransport
NewRateLimitTransport will return a new transport that provides rate limiting capability based on the provided limit and burst tokens. It also needs the base RountTripper that will be called in case the rate limit is not needed
type RepositoriesService ¶
type RepositoriesService interface { CreateStatus(ctx context.Context, owner, repo, ref string, status *github.RepoStatus) (*github.RepoStatus, *github.Response, error) Get(ctx context.Context, owner, repo string) (*github.Repository, *github.Response, error) GetBranch(ctx context.Context, owner, repo, branch string) (*github.Branch, *github.Response, error) GetCombinedStatus(ctx context.Context, owner, repo, ref string, opts *github.ListOptions) (*github.CombinedStatus, *github.Response, error) ListTeams(ctx context.Context, owner string, repo string, opts *github.ListOptions) ([]*github.Team, *github.Response, error) ListStatuses(ctx context.Context, owner, repo, ref string, opts *github.ListOptions) ([]*github.RepoStatus, *github.Response, error) }
type Repository ¶
type Repository struct { Owner string Name string BuildStatusContext string JenkinsServer string InstanceSetupScript string InstanceSetupUpgradeScript string JobName string }
func GetRepository ¶
func GetRepository(repositories []*Repository, owner, name string) (*Repository, bool)
type Server ¶
type Server struct { Config *Config Store store.Store GithubClient *GithubClient CircleCiClient *circleci.Client OrgMembers []string Builds buildsInterface StartTime time.Time Metrics MetricsProvider // contains filtered or unexported fields }
Server is the mattermod server.
func (*Server) AutoMergePR ¶
func (*Server) CheckPRActivity ¶
func (s *Server) CheckPRActivity()
func (*Server) CheckTestServerLifeTime ¶
func (s *Server) CheckTestServerLifeTime()
CheckTestServerLifeTime checks the age of the test server and kills if reach the limit
func (*Server) CleanOutdatedPRs ¶
func (s *Server) CleanOutdatedPRs()
func (*Server) CleanUpLabels ¶
func (s *Server) CleanUpLabels(pr *model.PullRequest)
func (*Server) GetAwsConfig ¶
func (*Server) GetIssueFromGithub ¶
func (*Server) GetPullRequestFromGithub ¶
func (s *Server) GetPullRequestFromGithub(ctx context.Context, pullRequest *github.PullRequest) (*model.PullRequest, error)
func (*Server) GetUpdateChecks ¶
func (*Server) IsBotUserFromCLAExclusionsList ¶
func (*Server) IsOrgMember ¶
func (*Server) RefreshMembers ¶
func (s *Server) RefreshMembers()
type WebhookValidationError ¶
type WebhookValidationError struct {
// contains filtered or unexported fields
}
WebhookValidationError contains an error in the webhook payload.
func (*WebhookValidationError) Error ¶
func (e *WebhookValidationError) Error() string
Error implements the error interface.
Source Files ¶
- auto_merge.go
- autoassign.go
- block_pr_merge.go
- build_mobile_apps.go
- builds.go
- builds_mocked.go
- cherry_pick.go
- circleci.go
- cla.go
- community.go
- config.go
- enterprise.go
- github.go
- github_client.go
- github_pr.go
- issue.go
- issue_handler.go
- metrics.go
- pull_request.go
- rate_limit.go
- response_writer_wrapper.go
- server.go
- spinmint.go
- translations.go
- update_branch.go
- utils.go
- validate_signature.go
- webhook.go