providers

package
v0.0.0-...-2f0a4f1 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2023 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoGithubClient    = errors.New("no github client configured for owner")
	ErrNoGithubGQLClient = errors.New("no github gql client configured for owner")
)

Functions

func NewGithubTokenSource

func NewGithubTokenSource(client AppClient, installationID int64) oauth2.TokenSource

Types

type AppClient

type AppClient interface {
	GetInstallations(ctx context.Context) ([]model.Installation, error)
	GetAccessToken(ctx context.Context, installationID int64) (*github.InstallationToken, error)
}

func NewAppClient

func NewAppClient(baseURL string, appID int64, keyEnclave *memguard.Enclave) (AppClient, error)

NewAppClient returns a new instance of the GitHub client.

type AppsTransport

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

AppsTransport provides a http.RoundTripper by wrapping an existing http.RoundTripper and provides GitHub Apps authentication as a GitHub App.

client can also be overwritten, and is useful to change to one which provides retry logic if you do experience retryable errors.

See https://developer.github.com/apps/building-integrations/setting-up-and-registering-github-apps/about-authentication-options-for-github-apps/

func NewAppsTransport

func NewAppsTransport(baseUrl string, tr http.RoundTripper, appID int64, key *memguard.Enclave) *AppsTransport

NewAppsTransport returns an AppsTransport using a memguard.Enclave containing a crypto/rsa.(*PrivateKey).

func (*AppsTransport) RoundTrip

func (t *AppsTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper interface.

type InstallationClient

type InstallationClient interface {
	GetRateLimits(ctx context.Context, owner string) (model.RateLimits, error)

	GetUser(ctx context.Context, owner, login string) (model.User, error)

	GetReposByOwner(ctx context.Context, owner string) ([]model.Repository, error)
	GetRepo(ctx context.Context, owner, repoName string) (model.Repository, error)

	PostIssue(ctx context.Context, owner, repoName string, issue model.IssueRequest) error
	UpdateIssue(ctx context.Context, owner, repoName string, number int, issue model.IssueRequest) error
	GetIssuesByRepo(ctx context.Context, owner, repoName string, options IssueListByRepoOptions) ([]model.Issue, error)
	GetEnrichedIssues(ctx context.Context, owner, repoName string, state model.IssueState) (map[int]model.EnrichedIssue, error)
	PutIssue(ctx context.Context, owner, repoName string, issue model.IssueRequest) error

	EnrichIssue(ctx context.Context, owner, repoName string, issues model.Issue) model.EnrichedIssue

	GetPullRequests(ctx context.Context, owner, repoName string) ([]model.PullRequest, error)
	PostPullRequest(ctx context.Context, owner, repoName string, pullRequestType model.PullRequestType, title, body, head, base string) (model.PullRequest, error)
	GetIssuePullRequest(ctx context.Context, owner, repoName string, issueNumber int) (*string, error)

	GetIssueEvents(ctx context.Context, owner, repoName string, issueNumber int) ([]model.IssueEvent, error)
	ValidateWebHookEvent(request *http.Request) (interface{}, error)

	GetComments(ctx context.Context, owner, repoName string, issueNumber int) ([]model.IssueComment, error)
	PostComment(ctx context.Context, owner, repoName string, issueNumber int, comment string) error
	UpdateComment(ctx context.Context, owner, repoName string, commentID int64, comment string) error
	DeleteComment(ctx context.Context, owner, repoName string, commentID int64) error

	GetLabels(ctx context.Context, owner, repoName string) ([]model.Label, error)
	PostLabel(ctx context.Context, owner, repoName string, label model.Label) error

	GetFile(ctx context.Context, owner, repoName, name string) (model.File, error)
	GetBranches(ctx context.Context, owner, repoName string) ([]string, error)
	GetCommitHash(ctx context.Context, owner, repoName, branchName string) (string, error)
	PostBranch(ctx context.Context, owner, repoName, branchName, commitHash string) error
	PostFile(ctx context.Context, owner, repoName, branch, path, content, message, authorName, authorEmail, authorLogin string) error
	UpdateFile(ctx context.Context, owner, repoName, branch, path, content, message, authorName, authorEmail, authorLogin, sha string) error

	AddInstallation(owner string, installationID int64) error
	AddGitHubClient(owner string, client *github.Client)
	CheckInstallation(owner string) bool
}

func NewInstallationClient

func NewInstallationClient(baseURL string, appClient AppClient, installations map[string]int64, webhookSecret, famedLabel string, redTeamLogins map[string]string) (InstallationClient, error)

NewInstallationClient returns a new instance of the GitHub client.

type IssueListByRepoOptions

type IssueListByRepoOptions struct {
	Labels   []string
	State    *model.IssueState
	Assignee *string
}

IssueListByRepoOptions specifies filtering options to be passed to the GetIssuesByRepo method.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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