Documentation
¶
Overview ¶
Package github provides a client for the GitHub REST API.
Index ¶
- type Client
- func (c *Client) ListTeamRepos(ctx context.Context, org, teamSlug string) ([]Repository, error)
- func (c *Client) ListUserTeams(ctx context.Context, org string) ([]Team, error)
- func (c *Client) ListWorkflowRuns(ctx context.Context, owner, repo string, workflowID int64, branch string, ...) ([]WorkflowRun, error)
- func (c *Client) ListWorkflows(ctx context.Context, owner, repo string) ([]Workflow, error)
- func (c *Client) TestConnection(ctx context.Context) error
- func (c *Client) WhoAmI(ctx context.Context) (*User, error)
- func (c *Client) WithDebug(v bool) *Client
- func (c *Client) WithDumpResponses(v bool) *Client
- type Credentials
- type Repository
- type RepositoryOwner
- type Team
- type TeamOrg
- type User
- type Workflow
- type WorkflowListResponse
- type WorkflowRun
- type WorkflowRunsResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the GitHub API client backed by go-gh.
func NewClient ¶
func NewClient(creds Credentials) (*Client, error)
NewClient creates a new GitHub API client using go-gh.
func NewClientWithTransport ¶
func NewClientWithTransport(creds Credentials, transport http.RoundTripper) (*Client, error)
NewClientWithTransport creates a GitHub API client with a custom HTTP transport. Intended for use in tests (e.g. pointing the client at an httptest.Server).
func (*Client) ListTeamRepos ¶
ListTeamRepos lists repositories for a team, handling Link-header pagination.
func (*Client) ListUserTeams ¶
ListUserTeams lists teams for the authenticated user, filtered to a specific org.
func (*Client) ListWorkflowRuns ¶
func (c *Client) ListWorkflowRuns(ctx context.Context, owner, repo string, workflowID int64, branch string, from, to time.Time) ([]WorkflowRun, error)
ListWorkflowRuns lists runs for a specific workflow, filtered by date range.
func (*Client) ListWorkflows ¶
ListWorkflows lists GitHub Actions workflows for a repository.
func (*Client) TestConnection ¶
TestConnection verifies the GitHub credentials work.
func (*Client) WhoAmI ¶
WhoAmI returns the authenticated GitHub user. Useful for printing a "Connected as ..." line after credentials are saved.
func (*Client) WithDumpResponses ¶
WithDumpResponses toggles full response-body dumping. Off by default.
type Credentials ¶
type Credentials struct {
Token string // Personal access token or GitHub App token
Org string // GitHub organization name
}
Credentials holds GitHub authentication details.
type Repository ¶
type Repository struct {
ID int64 `json:"id"`
Name string `json:"name"`
FullName string `json:"full_name"`
Owner RepositoryOwner `json:"owner"`
Private bool `json:"private"`
Archived bool `json:"archived"`
HTMLURL string `json:"html_url"`
}
Repository represents a GitHub repository.
type RepositoryOwner ¶
type RepositoryOwner struct {
Login string `json:"login"`
}
RepositoryOwner represents the owner of a GitHub repository.
type Team ¶
type Team struct {
ID int64 `json:"id"`
Slug string `json:"slug"`
Name string `json:"name"`
Organization TeamOrg `json:"organization"`
}
Team represents a GitHub team.
type TeamOrg ¶
type TeamOrg struct {
Login string `json:"login"`
}
TeamOrg represents the organization a team belongs to.
type User ¶
User is the subset of GitHub's /user response we care about. Populated by WhoAmI for the "Connected as ..." setup-confirmation line.
type Workflow ¶
type Workflow struct {
ID int64 `json:"id"`
Name string `json:"name"`
Path string `json:"path"`
State string `json:"state"`
}
Workflow represents a GitHub Actions workflow.
type WorkflowListResponse ¶
type WorkflowListResponse struct {
TotalCount int `json:"total_count"`
Workflows []Workflow `json:"workflows"`
}
WorkflowListResponse represents the response from listing workflows.
type WorkflowRun ¶
type WorkflowRun struct {
ID int64 `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
Conclusion string `json:"conclusion"`
HeadBranch string `json:"head_branch"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
RunNumber int `json:"run_number"`
HTMLURL string `json:"html_url"`
}
WorkflowRun represents a single GitHub Actions workflow run.
type WorkflowRunsResponse ¶
type WorkflowRunsResponse struct {
TotalCount int `json:"total_count"`
WorkflowRuns []WorkflowRun `json:"workflow_runs"`
}
WorkflowRunsResponse represents the response from listing workflow runs.