Documentation
¶
Index ¶
- func CheckRunPassed(checkRun CheckRun) bool
- func CheckSuitePassed(checkSuite CheckSuite) bool
- func ExpectedCheckPassed(expectedContext githubv4.String, checkRuns []CheckRun, ...) bool
- func GetVCSStatusNameFromRequiredCheck(requiredCheck githubv4.String) string
- func StatusContextPassed(statusContext StatusContext, vcsstatusname string) bool
- type AnonymousCredentials
- type AppCredentials
- type CheckRun
- type CheckSuite
- type Client
- func (g *Client) CreateComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, comment string, ...) error
- func (g *Client) DiscardReviews(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) error
- func (g *Client) ExchangeCode(logger logging.SimpleLogging, code string) (*GithubAppTemporarySecrets, error)
- func (g *Client) ExpectedWorkflowPassed(expectedWorkflow WorkflowFileReference, checkRuns []CheckRun) (bool, error)
- func (g *Client) GetChildTeams(logger logging.SimpleLogging, repo models.Repo, teamSlug string) ([]string, error)
- func (g *Client) GetCloneURL(logger logging.SimpleLogging, _ models.VCSHostType, repo string) (string, error)
- func (g *Client) GetFileContent(logger logging.SimpleLogging, repo models.Repo, branch string, fileName string) (bool, []byte, error)
- func (g *Client) GetModifiedFiles(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
- func (g *Client) GetPullLabels(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
- func (g *Client) GetPullRequest(logger logging.SimpleLogging, repo models.Repo, num int) (*github.PullRequest, error)
- func (g *Client) GetPullRequestMergeabilityInfo(repo models.Repo, pull *github.PullRequest) (reviewDecision githubv4.String, requiredChecks []githubv4.String, ...)
- func (g *Client) GetTeamNamesForUser(logger logging.SimpleLogging, repo models.Repo, user models.User) ([]string, error)
- func (g *Client) HidePrevCommandComments(logger logging.SimpleLogging, repo models.Repo, pullNum int, command string, ...) error
- func (g *Client) IsMergeableMinusApply(logger logging.SimpleLogging, repo models.Repo, pull *github.PullRequest, ...) (bool, error)
- func (g *Client) LookupRepoId(repo githubv4.String) (githubv4.Int, error)
- func (g *Client) MarkdownPullLink(pull models.PullRequest) (string, error)
- func (g *Client) MergePull(logger logging.SimpleLogging, pull models.PullRequest, ...) error
- func (g *Client) PullIsApproved(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error)
- func (g *Client) PullIsMergeable(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, ...) (models.MergeableStatus, error)
- func (g *Client) ReactToComment(logger logging.SimpleLogging, repo models.Repo, _ int, commentID int64, ...) error
- func (g *Client) SupportsSingleFileDownload(_ models.Repo) bool
- func (g *Client) UpdateStatus(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, ...) error
- func (g *Client) WorkflowRunMatchesWorkflowFileReference(workflowRunFile WorkflowRunFile, workflowFileReference WorkflowFileReference) (bool, error)
- type Config
- type Credentials
- type GitHubRepoIdCache
- type GithubAppTemporarySecrets
- type GithubPRReviewSummary
- type GithubPullRequestGetter
- type GithubRepoIdCacheEntry
- type GithubReview
- type IGithubClient
- type InstrumentedGithubClient
- type PageInfo
- type StatusContext
- type TokenRotator
- type UserCredentials
- type UserTransport
- type WorkflowFileReference
- type WorkflowRun
- type WorkflowRunFile
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckRunPassed ¶
func CheckSuitePassed ¶
func CheckSuitePassed(checkSuite CheckSuite) bool
func ExpectedCheckPassed ¶
func StatusContextPassed ¶
func StatusContextPassed(statusContext StatusContext, vcsstatusname string) bool
Types ¶
type AnonymousCredentials ¶
type AnonymousCredentials struct{}
GithubAnonymousCredentials expose no credentials.
func (*AnonymousCredentials) Client ¶
func (c *AnonymousCredentials) Client() (*http.Client, error)
Client returns a client with no credentials.
func (*AnonymousCredentials) GetToken ¶
func (c *AnonymousCredentials) GetToken() (string, error)
GetToken returns an empty token.
func (*AnonymousCredentials) GetUser ¶
func (c *AnonymousCredentials) GetUser() (string, error)
GetUser returns the username for these credentials.
type AppCredentials ¶
type AppCredentials struct {
AppID int64
Key []byte
Hostname string
InstallationID int64
AppSlug string
// contains filtered or unexported fields
}
GithubAppCredentials implements GithubCredentials for github app installation token flow.
func (*AppCredentials) Client ¶
func (c *AppCredentials) Client() (*http.Client, error)
Client returns a github app installation client.
func (*AppCredentials) GetToken ¶
func (c *AppCredentials) GetToken() (string, error)
GetToken returns a fresh installation token.
func (*AppCredentials) GetUser ¶
func (c *AppCredentials) GetUser() (string, error)
GetUser returns the username for these credentials.
type CheckRun ¶
type CheckSuite ¶
type CheckSuite struct {
Conclusion githubv4.String
WorkflowRun *WorkflowRun
}
func (CheckSuite) Copy ¶
func (original CheckSuite) Copy() CheckSuite
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is used to perform GitHub actions.
func New ¶
func New(hostname string, credentials Credentials, config Config, maxCommentsPerCommand int, logger logging.SimpleLogging) (*Client, error)
func (*Client) CreateComment ¶
func (g *Client) CreateComment(logger logging.SimpleLogging, repo models.Repo, pullNum int, comment string, command string) error
CreateComment creates a comment on the pull request. If comment length is greater than the max comment length we split into multiple comments.
func (*Client) DiscardReviews ¶
func (g *Client) DiscardReviews(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) error
DiscardReviews dismisses all reviews on a pull request
func (*Client) ExchangeCode ¶
func (g *Client) ExchangeCode(logger logging.SimpleLogging, code string) (*GithubAppTemporarySecrets, error)
ExchangeCode returns a newly created app's info
func (*Client) ExpectedWorkflowPassed ¶
func (g *Client) ExpectedWorkflowPassed(expectedWorkflow WorkflowFileReference, checkRuns []CheckRun) (bool, error)
func (*Client) GetChildTeams ¶ added in v0.45.0
func (g *Client) GetChildTeams(logger logging.SimpleLogging, repo models.Repo, teamSlug string) ([]string, error)
GetChildTeams returns the slugs of the direct child teams of the given team. Use this with fetchDescendantTeams in the command runner to expand an allowlisted team to all its descendants, supporting GitHub team hierarchy. https://docs.github.com/en/graphql/reference/objects#team
func (*Client) GetCloneURL ¶
func (g *Client) GetCloneURL(logger logging.SimpleLogging, _ models.VCSHostType, repo string) (string, error)
func (*Client) GetFileContent ¶
func (g *Client) GetFileContent(logger logging.SimpleLogging, repo models.Repo, branch string, fileName string) (bool, []byte, error)
GetFileContent a repository file content from VCS (which support fetch a single file from repository) The first return value indicates whether the repo contains a file or not if BaseRepo had a file, its content will placed on the second return value
func (*Client) GetModifiedFiles ¶
func (g *Client) GetModifiedFiles(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
GetModifiedFiles returns the names of files that were modified in the pull request relative to the repo root, e.g. parent/child/file.txt.
func (*Client) GetPullLabels ¶
func (g *Client) GetPullLabels(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) ([]string, error)
func (*Client) GetPullRequest ¶
func (g *Client) GetPullRequest(logger logging.SimpleLogging, repo models.Repo, num int) (*github.PullRequest, error)
GetPullRequest returns the pull request.
func (*Client) GetPullRequestMergeabilityInfo ¶
func (g *Client) GetPullRequestMergeabilityInfo( repo models.Repo, pull *github.PullRequest, ) ( reviewDecision githubv4.String, requiredChecks []githubv4.String, requiredWorkflows []WorkflowFileReference, checkRuns []CheckRun, statusContexts []StatusContext, pendingRequiredReviewerApproval bool, err error, )
func (*Client) GetTeamNamesForUser ¶
func (g *Client) GetTeamNamesForUser(logger logging.SimpleLogging, repo models.Repo, user models.User) ([]string, error)
GetTeamNamesForUser returns the names of the teams or groups that the user belongs to (in the organization the repository belongs to). https://docs.github.com/en/graphql/reference/objects#organization
func (*Client) HidePrevCommandComments ¶
func (*Client) IsMergeableMinusApply ¶
func (g *Client) IsMergeableMinusApply(logger logging.SimpleLogging, repo models.Repo, pull *github.PullRequest, vcsstatusname string, ignoreVCSStatusNames []string) (bool, error)
IsMergeableMinusApply checks review decision (which takes into account CODEOWNERS) and required checks for PR (excluding the atlantis apply check).
func (*Client) LookupRepoId ¶
func (*Client) MarkdownPullLink ¶
func (g *Client) MarkdownPullLink(pull models.PullRequest) (string, error)
MarkdownPullLink specifies the string used in a pull request comment to reference another pull request.
func (*Client) MergePull ¶
func (g *Client) MergePull(logger logging.SimpleLogging, pull models.PullRequest, pullOptions models.PullRequestOptions) error
MergePull merges the pull request.
func (*Client) PullIsApproved ¶
func (g *Client) PullIsApproved(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest) (approvalStatus models.ApprovalStatus, err error)
PullIsApproved returns true if the pull request was approved.
func (*Client) PullIsMergeable ¶
func (g *Client) PullIsMergeable(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, vcsstatusname string, ignoreVCSStatusNames []string) (models.MergeableStatus, error)
PullIsMergeable returns true if the pull request is mergeable.
func (*Client) ReactToComment ¶
func (g *Client) ReactToComment(logger logging.SimpleLogging, repo models.Repo, _ int, commentID int64, reaction string) error
ReactToComment adds a reaction to a comment.
func (*Client) SupportsSingleFileDownload ¶
func (*Client) UpdateStatus ¶
func (g *Client) UpdateStatus(logger logging.SimpleLogging, repo models.Repo, pull models.PullRequest, state models.CommitStatus, src string, description string, url string) error
UpdateStatus updates the status badge on the pull request. See https://github.com/blog/1227-commit-status-api.
func (*Client) WorkflowRunMatchesWorkflowFileReference ¶
func (g *Client) WorkflowRunMatchesWorkflowFileReference(workflowRunFile WorkflowRunFile, workflowFileReference WorkflowFileReference) (bool, error)
type Config ¶
type Config struct {
AllowMergeableBypassApply bool
}
GithubConfig allows for custom github-specific functionality and behavior
type Credentials ¶
type Credentials interface {
Client() (*http.Client, error)
GetToken() (string, error)
GetUser() (string, error)
}
GithubCredentials handles creating http.Clients that authenticate.
type GitHubRepoIdCache ¶
type GitHubRepoIdCache struct {
// contains filtered or unexported fields
}
func NewGitHubRepoIdCache ¶
func NewGitHubRepoIdCache() GitHubRepoIdCache
type GithubAppTemporarySecrets ¶
type GithubAppTemporarySecrets struct {
// ID is the app id.
ID int64
// Key is the app's PEM-encoded key.
Key string
// Name is the app name.
Name string
// WebhookSecret is the generated webhook secret for this app.
WebhookSecret string
// URL is a link to the app, like https://github.com/apps/octoapp.
URL string
}
GithubAppTemporarySecrets holds app credentials obtained from github after creation.
type GithubPRReviewSummary ¶
type GithubPRReviewSummary struct {
ReviewDecision githubv4.String
Reviews []GithubReview
}
type GithubPullRequestGetter ¶
type GithubPullRequestGetter interface {
GetPullRequest(logger logging.SimpleLogging, repo models.Repo, pullNum int) (*github.PullRequest, error)
}
type GithubRepoIdCacheEntry ¶
type GithubReview ¶
type IGithubClient ¶
type IGithubClient interface {
vcs.Client
GithubPullRequestGetter
}
IGithubClient exists to bridge the gap between GithubPullRequestGetter and Client interface to allow for a single instrumented client
func NewInstrumentedGithubClient ¶
func NewInstrumentedGithubClient(client *Client, statsScope tally.Scope, logger logging.SimpleLogging) IGithubClient
NewInstrumentedGithubClient creates a client proxy responsible for gathering stats and logging
type InstrumentedGithubClient ¶
type InstrumentedGithubClient struct {
*common.InstrumentedClient
PullRequestGetter GithubPullRequestGetter
StatsScope tally.Scope
Logger logging.SimpleLogging
}
InstrumentedGithubClient should delegate to the underlying InstrumentedClient for vcs provider-agnostic methods and implement solely any github specific interfaces.
func (*InstrumentedGithubClient) GetPullRequest ¶
func (c *InstrumentedGithubClient) GetPullRequest(logger logging.SimpleLogging, repo models.Repo, pullNum int) (*github.PullRequest, error)
type StatusContext ¶
type TokenRotator ¶
type TokenRotator interface {
Run()
GenerateJob() (scheduled.JobDefinition, error)
}
GithubTokenRotator continuously tries to rotate the github app access token every 30 seconds and writes the ~/.git-credentials file
func NewTokenRotator ¶
func NewTokenRotator( log logging.SimpleLogging, githubCredentials Credentials, githubHostname string, gitUser string, homeDirPath string) TokenRotator
type UserCredentials ¶
GithubUserCredentials implements GithubCredentials for the personal auth token flow.
func (*UserCredentials) Client ¶
func (c *UserCredentials) Client() (*http.Client, error)
Client returns a client for basic auth user credentials.
func (*UserCredentials) GetToken ¶
func (c *UserCredentials) GetToken() (string, error)
GetToken returns the user token.
func (*UserCredentials) GetUser ¶
func (c *UserCredentials) GetUser() (string, error)
GetUser returns the username for these credentials.
type UserTransport ¶
type UserTransport struct {
Credentials *UserCredentials
Transport *github.BasicAuthTransport
}
type WorkflowFileReference ¶
type WorkflowFileReference struct {
Path githubv4.String
RepositoryId githubv4.Int
Sha *githubv4.String
}
func (WorkflowFileReference) Copy ¶
func (original WorkflowFileReference) Copy() WorkflowFileReference
type WorkflowRun ¶
type WorkflowRun struct {
File *WorkflowRunFile
RunNumber githubv4.Int
}
func (WorkflowRun) Copy ¶
func (original WorkflowRun) Copy() WorkflowRun