github

package
v0.0.0-...-c92e1c5 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const EnvGhAppId = "GH_APP_ID"
View Source
const FilenameTheClaPem string = "the-cla.pem"

Variables

This section is empty.

Functions

func EvaluatePullRequest

func EvaluatePullRequest(logger *zap.Logger, postgres db.IClaDB, evalInfo *types.EvaluationInfo, claVersion string) error

func GetAppId

func GetAppId() (appId int64, err error)

func HandlePullRequest

func HandlePullRequest(logger *zap.Logger, postgres db.IClaDB, payload webhook.PullRequestPayload, appId int64, claVersion string) error

func ReviewPriorPRs

func ReviewPriorPRs(logger *zap.Logger, postgres db.IClaDB, user *types.UserSignature) (err error)

func SetupMockGHJWT

func SetupMockGHJWT() (resetImpl func())

func SetupTestPemFile

func SetupTestPemFile(t *testing.T) (resetImpl func())

Types

type AppsMock

type AppsMock struct {
	// contains filtered or unexported fields
}

func (*AppsMock) Get

func (a *AppsMock) Get(ctx context.Context, appSlug string) (*github.App, *github.Response, error)

func (*AppsMock) GetInstallation

func (a *AppsMock) GetInstallation(ctx context.Context, id int64) (*github.Installation, *github.Response, error)

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 GHClient

type GHClient struct {
	Repositories RepositoriesService
	Users        UsersService
	PullRequests PullRequestsService
	Issues       IssuesService
}

GHClient manages communication with the GitHub API. https://github.com/google/go-github/issues/113

type GHCreator

type GHCreator struct{}

GHCreator implements GHInterface.

func (*GHCreator) NewClient

func (g *GHCreator) NewClient(httpClient *http.Client) GHClient

NewClient returns a new GHInterface instance.

type GHInterface

type GHInterface interface {
	NewClient(httpClient *http.Client) GHClient
}

GHInterface defines all necessary methods. https://godoc.org/github.com/google/go-github/github#NewClient

var GHImpl GHInterface = &GHCreator{}

type GHInterfaceMock

type GHInterfaceMock struct {
	RepositoriesMock RepositoriesMock
	UsersMock        UsersMock
	PullRequestsMock PullRequestsMock
	IssuesMock       IssuesMock
}

GHInterfaceMock implements GHInterface.

func (*GHInterfaceMock) NewClient

func (g *GHInterfaceMock) NewClient(httpClient *http.Client) GHClient

NewClient something

type GHJWTClient

type GHJWTClient struct {
	// contains filtered or unexported fields
}

func (*GHJWTClient) Get

func (ghj *GHJWTClient) Get() (app *github.App, err error)

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 GHJWTInterface

type GHJWTInterface interface {
	NewJWTClient(httpClient *http.Client, installID int64) IGitHubJWTClient
}
var GHJWTImpl GHJWTInterface = &GHJWTCreator{}

type GHJWTMock

type GHJWTMock struct {
	AppsMock AppsMock
}

func (*GHJWTMock) NewJWTClient

func (gj *GHJWTMock) NewJWTClient(httpClient *http.Client, installID int64) IGitHubJWTClient

type IGitHubJWTClient

type IGitHubJWTClient interface {
	Get() (*github.App, error)
	GetInstallInfo() (*github.Installation, error)
}

type IssuesMock

type IssuesMock struct {
	MockGetLabelResponse *github.Response

	MockRemoveLabelResponse *github.Response
	// contains filtered or unexported fields
}

func (*IssuesMock) AddLabelsToIssue

func (i *IssuesMock) AddLabelsToIssue(ctx context.Context, owner string, repo string, number int, labels []string) ([]*github.Label, *github.Response, error)

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 (i *IssuesMock) CreateLabel(ctx context.Context, owner string, repo string, label *github.Label) (*github.Label, *github.Response, error)

func (*IssuesMock) GetLabel

func (i *IssuesMock) GetLabel(ctx context.Context, owner string, repo string, labelName string) (*github.Label, *github.Response, error)

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

func (i *IssuesMock) ListLabelsByIssue(ctx context.Context, owner string, repo string, issueNumber int, opts *github.ListOptions) ([]*github.Label, *github.Response, error)

func (*IssuesMock) RemoveLabelForIssue

func (i *IssuesMock) RemoveLabelForIssue(ctx context.Context, owner string, repo string, number int, label string) (*github.Response, error)

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 PullRequestsMock

type PullRequestsMock struct {
	// contains filtered or unexported fields
}

PullRequestsMock mocks PullRequestsService

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 PullRequestsService

type PullRequestsService interface {
	ListCommits(ctx context.Context, owner string, repo string, number int, opts *github.ListOptions) ([]*github.RepositoryCommit, *github.Response, error)
}

PullRequestsService 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 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) (*github.RepoStatus, *github.Response, error)

func (*RepositoriesMock) Get

Get returns a repository.

func (*RepositoriesMock) IsCollaborator

func (r *RepositoriesMock) IsCollaborator(ctx context.Context, owner, repo, user string) (bool, *github.Response, error)

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 UsersMock

type UsersMock struct {
	// contains filtered or unexported fields
}

UsersMock mocks UsersService

func (*UsersMock) Get

Get returns a user.

type UsersService

type UsersService interface {
	Get(context.Context, string) (*github.User, *github.Response, error)
}

UsersService handles communication with the user related methods of the GitHub API. https://godoc.org/github.com/google/go-github/github#UsersService

Jump to

Keyboard shortcuts

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