Documentation
¶
Overview ¶
Package github provides the functionality to send requests to the GitHub API.
Index ¶
- Constants
- type Config
- type GitHub
- type GitHubClient
- func (g *GitHubClient) CloseIssue(ctx context.Context, owner, repo string, number int) error
- func (g *GitHubClient) CreateIssue(ctx context.Context, owner, repo, title, body string, ...) (*Issue, error)
- func (g *GitHubClient) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)
- func (g *GitHubClient) DeleteIssueComment(ctx context.Context, owner, repo string, id int64) error
- func (g *GitHubClient) ListIssueComments(ctx context.Context, owner, repo string, number int, ...) (*IssueCommentResponse, error)
- func (g *GitHubClient) ListIssues(ctx context.Context, owner, repo string, opts *github.IssueListByRepoOptions) ([]*Issue, error)
- func (g *GitHubClient) ListPullRequestsForCommit(ctx context.Context, owner, repo, sha string, ...) (*PullRequestResponse, error)
- func (g *GitHubClient) ListRepositories(ctx context.Context, owner string, opts *github.RepositoryListByOrgOptions) ([]*Repository, error)
- func (g *GitHubClient) RepoUserPermissionLevel(ctx context.Context, owner, repo, user string) (string, error)
- func (g *GitHubClient) UpdateIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
- type Issue
- type IssueComment
- type IssueCommentResponse
- type MockGitHubClient
- func (m *MockGitHubClient) CloseIssue(ctx context.Context, owner, repo string, number int) error
- func (m *MockGitHubClient) CreateIssue(ctx context.Context, owner, repo, title, body string, ...) (*Issue, error)
- func (m *MockGitHubClient) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)
- func (m *MockGitHubClient) DeleteIssueComment(ctx context.Context, owner, repo string, id int64) error
- func (m *MockGitHubClient) ListIssueComments(ctx context.Context, owner, repo string, number int, ...) (*IssueCommentResponse, error)
- func (m *MockGitHubClient) ListIssues(ctx context.Context, owner, repo string, opts *github.IssueListByRepoOptions) ([]*Issue, error)
- func (m *MockGitHubClient) ListPullRequestsForCommit(ctx context.Context, owner, repo, sha string, ...) (*PullRequestResponse, error)
- func (m *MockGitHubClient) ListRepositories(ctx context.Context, owner string, opts *github.RepositoryListByOrgOptions) ([]*Repository, error)
- func (m *MockGitHubClient) RepoUserPermissionLevel(ctx context.Context, owner, repo, user string) (string, error)
- func (m *MockGitHubClient) UpdateIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
- type Option
- type Pagination
- type PullRequest
- type PullRequestResponse
- type Repository
- type Request
Constants ¶
const ( Closed = "closed" Open = "open" Any = "any" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
Config is the config values for the GitHub client.
type GitHub ¶
type GitHub interface {
// ListRepositories lists all repositories and returns details about the repositories.
ListRepositories(ctx context.Context, owner string, opts *github.RepositoryListByOrgOptions) ([]*Repository, error)
// ListIssues lists all issues and returns their numbers in a repository matching the given criteria.
ListIssues(ctx context.Context, owner, repo string, opts *github.IssueListByRepoOptions) ([]*Issue, error)
// CreateIssue creates an issue.
CreateIssue(ctx context.Context, owner, repo, title, body string, assignees, labels []string) (*Issue, error)
// CloseIssue closes an issue.
CloseIssue(ctx context.Context, owner, repo string, number int) error
// CreateIssueComment creates a comment for an issue or pull request.
CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)
// UpdateIssueComment updates an issue or pull request comment.
UpdateIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
// DeleteIssueComment deletes an issue or pull request comment.
DeleteIssueComment(ctx context.Context, owner, repo string, id int64) error
// ListIssueComments lists existing comments for an issue or pull request.
ListIssueComments(ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions) (*IssueCommentResponse, error)
// ListPullRequestsForCommit lists the pull requests associated with a commit.
ListPullRequestsForCommit(ctx context.Context, owner, repo, sha string, opts *github.PullRequestListOptions) (*PullRequestResponse, error)
// RepoUserPermissionLevel gets the repository permission level for a user. The possible permissions values
// are admin, write, read, none.
RepoUserPermissionLevel(ctx context.Context, owner, repo, user string) (string, error)
}
GitHub provides the minimum interface for sending requests to the GitHub API.
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient implements the GitHub interface.
func NewClient ¶
func NewClient(ctx context.Context, token string, opts ...Option) *GitHubClient
NewClient creates a new GitHub client.
func (*GitHubClient) CloseIssue ¶
CloseIssue closes an issue.
func (*GitHubClient) CreateIssue ¶
func (g *GitHubClient) CreateIssue(ctx context.Context, owner, repo, title, body string, assignees, labels []string) (*Issue, error)
CreateIssue creates an issue.
func (*GitHubClient) CreateIssueComment ¶
func (g *GitHubClient) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)
CreateIssueComment creates a comment for an issue or pull request.
func (*GitHubClient) DeleteIssueComment ¶
DeleteIssueComment deletes an issue or pull request comment.
func (*GitHubClient) ListIssueComments ¶
func (g *GitHubClient) ListIssueComments(ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions) (*IssueCommentResponse, error)
ListIssueComments lists existing comments for an issue or pull request.
func (*GitHubClient) ListIssues ¶
func (g *GitHubClient) ListIssues(ctx context.Context, owner, repo string, opts *github.IssueListByRepoOptions) ([]*Issue, error)
ListIssues lists all issues and returns their numbers in a repository matching the given criteria.
func (*GitHubClient) ListPullRequestsForCommit ¶
func (g *GitHubClient) ListPullRequestsForCommit(ctx context.Context, owner, repo, sha string, opts *github.PullRequestListOptions) (*PullRequestResponse, error)
ListPullRequestsForCommit lists the pull requests associated with a commit.
func (*GitHubClient) ListRepositories ¶
func (g *GitHubClient) ListRepositories(ctx context.Context, owner string, opts *github.RepositoryListByOrgOptions) ([]*Repository, error)
ListRepositories lists all repositories and returns details about the repositories.
func (*GitHubClient) RepoUserPermissionLevel ¶
func (g *GitHubClient) RepoUserPermissionLevel(ctx context.Context, owner, repo, user string) (string, error)
RepoUserPermissionLevel gets the repository permission level for a user. The possible permissions values are admin, write, read, none.
func (*GitHubClient) UpdateIssueComment ¶
func (g *GitHubClient) UpdateIssueComment(ctx context.Context, owner, repo string, id int64, body string) error
UpdateIssueComment updates an issue or pull request comment.
type IssueComment ¶
type IssueCommentResponse ¶
type IssueCommentResponse struct {
Comments []*IssueComment
Pagination *Pagination
}
type MockGitHubClient ¶
type MockGitHubClient struct {
Reqs []*Request
ListRepositoriesErr error
ListIssuesErr error
CreateIssueErr error
CloseIssueErr error
CreateIssueCommentsErr error
UpdateIssueCommentsErr error
DeleteIssueCommentsErr error
ListIssueCommentsErr error
ListIssueCommentResponse *IssueCommentResponse
ListPullRequestsForCommitErr error
RepoPermissionLevelErr error
RepoPermissionLevel string
// contains filtered or unexported fields
}
func (*MockGitHubClient) CloseIssue ¶
func (*MockGitHubClient) CreateIssue ¶
func (*MockGitHubClient) CreateIssueComment ¶
func (m *MockGitHubClient) CreateIssueComment(ctx context.Context, owner, repo string, number int, body string) (*IssueComment, error)
func (*MockGitHubClient) DeleteIssueComment ¶
func (*MockGitHubClient) ListIssueComments ¶
func (m *MockGitHubClient) ListIssueComments(ctx context.Context, owner, repo string, number int, opts *github.IssueListCommentsOptions) (*IssueCommentResponse, error)
func (*MockGitHubClient) ListIssues ¶
func (m *MockGitHubClient) ListIssues(ctx context.Context, owner, repo string, opts *github.IssueListByRepoOptions) ([]*Issue, error)
func (*MockGitHubClient) ListPullRequestsForCommit ¶
func (m *MockGitHubClient) ListPullRequestsForCommit(ctx context.Context, owner, repo, sha string, opts *github.PullRequestListOptions) (*PullRequestResponse, error)
func (*MockGitHubClient) ListRepositories ¶
func (m *MockGitHubClient) ListRepositories(ctx context.Context, owner string, opts *github.RepositoryListByOrgOptions) ([]*Repository, error)
func (*MockGitHubClient) RepoUserPermissionLevel ¶
func (*MockGitHubClient) UpdateIssueComment ¶
type Option ¶
Option is an optional config value for the GitHubClient.
func WithRetryInitialDelay ¶
WithRetryInitialDelay configures the initial delay time before sending a retry for the GitHub Client.
func WithRetryMaxAttempts ¶
WithRetryMaxAttempts configures the maximum number of retry attempts for the GitHub Client.
func WithRetryMaxDelay ¶
WithRetryMaxDelay configures the maximum delay time before sending a retry for the GitHub Client.
type Pagination ¶
type Pagination struct {
NextPage int
}
Pagination is the paging details for a list response.
type PullRequest ¶
type PullRequestResponse ¶
type PullRequestResponse struct {
PullRequests []*PullRequest
Pagination *Pagination
}
type Repository ¶
Repository is the GitHub Repository.