Documentation
¶
Index ¶
- Constants
- Variables
- func EvaluatePullRequest(logger *zap.Logger, postgres db.IClaDB, evalInfo *types.EvaluationInfo, ...) error
- func GetAppId() (appId int64, err error)
- func HandlePullRequest(logger *zap.Logger, postgres db.IClaDB, payload webhook.PullRequestPayload, ...) error
- func ReviewPriorPRs(logger *zap.Logger, postgres db.IClaDB, user *types.UserSignature) (err error)
- func SetupMockGHJWT() (resetImpl func())
- func SetupTestPemFile(t *testing.T) (resetImpl func())
- type AppsMock
- type AppsService
- type CommitsLister
- type GHClient
- type GHClientCreator
- type GHCreator
- type GHInterfaceMock
- type GHJWTClient
- type GHJWTCreator
- type GHJWTMock
- type IGitHubJWTClient
- type IssuesMock
- func (i *IssuesMock) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)
- func (i *IssuesMock) CreateComment(ctx context.Context, owner string, repo string, number int, ...) (*github.IssueComment, *github.Response, error)
- func (i *IssuesMock) CreateLabel(ctx context.Context, owner string, repo string, label *github.Label) (*github.Label, *github.Response, error)
- func (i *IssuesMock) GetLabel(ctx context.Context, owner string, repo string, labelName string) (*github.Label, *github.Response, error)
- func (i *IssuesMock) ListComments(ctx context.Context, owner string, repo string, number int, ...) ([]*github.IssueComment, *github.Response, error)
- func (i *IssuesMock) ListLabelsByIssue(ctx context.Context, owner string, repo string, issueNumber int, ...) ([]*github.Label, *github.Response, error)
- func (i *IssuesMock) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*github.Response, error)
- type IssuesService
- type JWTClientCreator
- type PullRequestsMock
- type RepositoriesMock
- func (r *RepositoriesMock) CreateStatus(ctx context.Context, owner, repo, ref string, status *github.RepoStatus) (retRepoStatus *github.RepoStatus, createStatusResponse *github.Response, ...)
- func (r *RepositoriesMock) Get(context.Context, string, string) (*github.Repository, *github.Response, error)
- func (r *RepositoriesMock) IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *github.Response, error)
- func (r *RepositoriesMock) ListStatuses(ctx context.Context, owner, repo, ref string, opts *github.ListOptions) ([]*github.RepoStatus, *github.Response, error)
- type RepositoriesService
- type UserGetter
- type UsersMock
Constants ¶
const EnvGhAppId = "GH_APP_ID"
Variables ¶
var FilenameTheClaPem = getpemlocation()
var MockAppSlug = "myAppSlug"
Functions ¶
func EvaluatePullRequest ¶
func HandlePullRequest ¶
func ReviewPriorPRs ¶
func SetupMockGHJWT ¶
func SetupMockGHJWT() (resetImpl func())
func SetupTestPemFile ¶
Types ¶
type AppsMock ¶
type AppsMock struct {
// contains filtered or unexported fields
}
type AppsService ¶
type AppsService interface {
// Get a single GitHub App. Passing the empty string will get
// the authenticated GitHub App.
Get(ctx context.Context, appSlug string) (*github.App, *github.Response, error)
GetInstallation(ctx context.Context, id int64) (*github.Installation, *github.Response, error)
}
AppsService provides access to the installation related functions in the GitHub API.
GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps/
type CommitsLister ¶ added in v1.0.0
type CommitsLister interface {
ListCommits(ctx context.Context, owner string, repo string, number int, opts *github.ListOptions) ([]*github.RepositoryCommit, *github.Response, error)
}
CommitsLister handles communication with the pull request related methods of the GitHub API.
GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/pulls/
type GHClient ¶
type GHClient struct {
Repositories RepositoriesService
Users UserGetter
PullRequests CommitsLister
Issues IssuesService
}
GHClient manages communication with the GitHub API. https://github.com/google/go-github/issues/113
type GHClientCreator ¶ added in v1.0.0
GHClientCreator defines all necessary methods. https://godoc.org/github.com/google/go-github/github#NewClient
var GHImpl GHClientCreator = &GHCreator{}
type GHInterfaceMock ¶
type GHInterfaceMock struct {
RepositoriesMock RepositoriesMock
UsersMock UsersMock
PullRequestsMock PullRequestsMock
IssuesMock IssuesMock
}
GHInterfaceMock implements GHClientCreator.
type GHJWTClient ¶
type GHJWTClient struct {
// contains filtered or unexported fields
}
func (*GHJWTClient) GetInstallInfo ¶
func (ghj *GHJWTClient) GetInstallInfo() (install *github.Installation, err error)
type GHJWTCreator ¶
type GHJWTCreator struct{}
func (*GHJWTCreator) NewJWTClient ¶
func (gj *GHJWTCreator) NewJWTClient(httpClient *http.Client, installID int64) IGitHubJWTClient
type GHJWTMock ¶
type GHJWTMock struct {
AppsMock AppsMock
}
func (*GHJWTMock) NewJWTClient ¶
func (gj *GHJWTMock) NewJWTClient(httpClient *http.Client, installID int64) IGitHubJWTClient
type IGitHubJWTClient ¶
type IssuesMock ¶
type IssuesMock struct {
MockGetLabelResponse *github.Response
MockRemoveLabelResponse *github.Response
// contains filtered or unexported fields
}
func (*IssuesMock) AddLabelsToIssue ¶
func (*IssuesMock) CreateComment ¶
func (i *IssuesMock) CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
func (*IssuesMock) CreateLabel ¶
func (*IssuesMock) ListComments ¶
func (i *IssuesMock) ListComments(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)
func (*IssuesMock) ListLabelsByIssue ¶
type IssuesService ¶
type IssuesService interface {
GetLabel(ctx context.Context, owner string, repo string, name string) (*github.Label, *github.Response, error)
ListLabelsByIssue(ctx context.Context, owner string, repo string, issueNumber int, opts *github.ListOptions) ([]*github.Label, *github.Response, error)
CreateLabel(ctx context.Context, owner string, repo string, label *github.Label) (*github.Label, *github.Response, error)
AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)
RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*github.Response, error)
CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
ListComments(ctx context.Context, owner string, repo string, number int, opts *github.IssueListCommentsOptions) ([]*github.IssueComment, *github.Response, error)
}
IssuesService handles communication with the issue related methods of the GitHub API.
GitHub API docs: https://docs.github.com/en/free-pro-team@latest/rest/reference/issues/
type JWTClientCreator ¶ added in v1.0.0
type JWTClientCreator interface {
NewJWTClient(httpClient *http.Client, installID int64) IGitHubJWTClient
}
var GHJWTImpl JWTClientCreator = &GHJWTCreator{}
type PullRequestsMock ¶
type PullRequestsMock struct {
// contains filtered or unexported fields
}
PullRequestsMock mocks CommitsLister
func (*PullRequestsMock) ListCommits ¶
func (p *PullRequestsMock) ListCommits(ctx context.Context, owner string, repo string, number int, opts *github.ListOptions) ([]*github.RepositoryCommit, *github.Response, error)
type RepositoriesMock ¶
type RepositoriesMock struct {
// contains filtered or unexported fields
}
RepositoriesMock mocks RepositoriesService
func (*RepositoriesMock) CreateStatus ¶
func (r *RepositoriesMock) CreateStatus(ctx context.Context, owner, repo, ref string, status *github.RepoStatus) (retRepoStatus *github.RepoStatus, createStatusResponse *github.Response, createStatusError error)
func (*RepositoriesMock) Get ¶
func (r *RepositoriesMock) Get(context.Context, string, string) (*github.Repository, *github.Response, error)
Get returns a repository.
func (*RepositoriesMock) IsCollaborator ¶
func (*RepositoriesMock) ListStatuses ¶
func (r *RepositoriesMock) ListStatuses(ctx context.Context, owner, repo, ref string, opts *github.ListOptions) ([]*github.RepoStatus, *github.Response, error)
type RepositoriesService ¶
type RepositoriesService interface {
Get(context.Context, string, string) (*github.Repository, *github.Response, error)
ListStatuses(ctx context.Context, owner, repo, ref string, opts *github.ListOptions) ([]*github.RepoStatus, *github.Response, error)
CreateStatus(ctx context.Context, owner, repo, ref string, status *github.RepoStatus) (*github.RepoStatus, *github.Response, error)
IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *github.Response, error)
}
RepositoriesService handles communication with the repository related methods of the GitHub API. https://godoc.org/github.com/google/go-github/github#RepositoriesService
type UserGetter ¶ added in v1.0.0
UserGetter handles communication with the user related methods of the GitHub API. https://godoc.org/github.com/google/go-github/github#UserGetter