Documentation
¶
Overview ¶
Package githubclient is Nosey's native GitHub adapter over go-github. It runs no gh subprocess and its exported API exposes no go-github types.
Index ¶
- Constants
- type Client
- func (c *Client) Authenticated() bool
- func (c *Client) CreatePullRequest(ctx context.Context, request CreatePullRequestRequest) (PullRequest, error)
- func (c *Client) CreateRepository(ctx context.Context, request CreateRepositoryRequest) (Repository, error)
- func (c *Client) FindPullRequest(ctx context.Context, owner, repo, head, base string) (PullRequest, bool, error)
- func (c *Client) GetRepository(ctx context.Context, owner, name string) (Repository, error)
- func (c *Client) UpdateDefaultWorkflowPermissions(ctx context.Context, owner, name string, permissions WorkflowPermissions) error
- type CreatePullRequestRequest
- type CreateRepositoryRequest
- type Error
- type Options
- type PullRequest
- type Repository
- type WorkflowPermissions
Constants ¶
const ( KindRateLimited gitclient.Kind = "GitHub rate limit exceeded" KindInvalid gitclient.Kind = "GitHub rejected the request" )
Kinds reuse gitclient's error classification; these add API-only cases.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a token-scoped GitHub API client for one host.
func New ¶
New resolves the host's token and constructs a Client. An Enterprise host gets a token only when gh knows it, GH_HOST names it, or Credentials.TrustedHosts lists it.
func (*Client) Authenticated ¶
Authenticated reports whether the client holds a token.
func (*Client) CreatePullRequest ¶
func (c *Client) CreatePullRequest(ctx context.Context, request CreatePullRequestRequest) (PullRequest, error)
CreatePullRequest opens a pull request.
func (*Client) CreateRepository ¶
func (c *Client) CreateRepository(ctx context.Context, request CreateRepositoryRequest) (Repository, error)
CreateRepository creates a repository for the authenticated user when Owner is that user or empty, otherwise in the organization named by Owner.
func (*Client) FindPullRequest ¶
func (c *Client) FindPullRequest(ctx context.Context, owner, repo, head, base string) (PullRequest, bool, error)
FindPullRequest returns the open pull request from head into base. Found is false when there is none. The head filter uses the repository owner.
func (*Client) GetRepository ¶
GetRepository returns owner/name.
func (*Client) UpdateDefaultWorkflowPermissions ¶
func (c *Client) UpdateDefaultWorkflowPermissions(ctx context.Context, owner, name string, permissions WorkflowPermissions) error
UpdateDefaultWorkflowPermissions sets the repository's Actions defaults.
type CreatePullRequestRequest ¶
type CreatePullRequestRequest struct {
Owner string
Repo string
Base string
Head string
Title string
Body string
}
CreatePullRequestRequest describes a new pull request.
type CreateRepositoryRequest ¶
CreateRepositoryRequest describes a new repository.
type Error ¶
type Error struct {
Kind gitclient.Kind
Op string
Status int
// RateReset is when a rate limit lifts, if known.
RateReset time.Time
Err error
}
Error is a classified API failure.
type Options ¶
type Options struct {
// Host is the GitHub host; empty means github.com. An Enterprise host is the
// origin host of the repository being operated on.
Host string
// Credentials resolves the token; nil uses the operating system's.
Credentials *gitclient.Credentials
// RequireAuth fails construction when no token is available. Use it for writes.
RequireAuth bool
// Timeout bounds each API request; zero uses 30 seconds.
Timeout time.Duration
// BaseURL replaces the API base URL. Test seam for httptest.
BaseURL string
}
Options configure a Client.
type PullRequest ¶
PullRequest is an open pull request.
type Repository ¶
type Repository struct {
Owner string
Name string
Private bool
DefaultBranch string
HTMLURL string
CloneURL string
SSHURL string
}
Repository describes a GitHub repository.
type WorkflowPermissions ¶
type WorkflowPermissions struct {
// Default is "read" or "write".
Default string
// CanApprovePullRequests lets Actions open and approve pull requests.
CanApprovePullRequests bool
}
WorkflowPermissions are a repository's default GitHub Actions permissions.