github

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const EnvGhAppId = "GH_APP_ID"

Variables

View Source
var FilenameTheClaPem = getpemlocation()
View Source
var MockAppSlug = "myAppSlug"

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 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

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

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

var GHImpl GHClientCreator = &GHCreator{}

type GHCreator

type GHCreator struct{}

GHCreator implements GHClientCreator.

func (*GHCreator) NewClient

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

NewClient returns a new GHClientCreator instance.

type GHInterfaceMock

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

GHInterfaceMock implements GHClientCreator.

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 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 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

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 UserGetter added in v1.0.0

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

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

type UsersMock

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

UsersMock mocks UserGetter

func (*UsersMock) Get

Get returns a user.

Jump to

Keyboard shortcuts

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