Documentation
¶
Overview ¶
Package github implements the provider interface for GitHub.
This package provides GitHub-specific API integration for repository operations including listing, cloning, and organization management.
Features ¶
- Repository listing (org and user)
- Token validation
- Rate limit management
- Pagination handling
- GitHub Enterprise Server (custom base URL)
Usage ¶
// baseURL="" targets github.com; set it for a GitHub Enterprise Server.
provider, err := github.NewProvider(token, baseURL)
if err != nil {
return err
}
repos, err := provider.ListOrganizationRepos(ctx, "myorg")
Index ¶
- type Provider
- func (p *Provider) BaseURL() string
- func (p *Provider) CreatePullRequest(ctx context.Context, in provider.CreatePullRequestInput) (*provider.PullRequest, error)
- func (p *Provider) FindPullRequest(ctx context.Context, owner, repo, head, base string) (*provider.PullRequest, error)
- func (p *Provider) GetRateLimit(ctx context.Context) (*provider.RateLimit, error)
- func (p *Provider) GetRepository(ctx context.Context, owner, repo string) (*provider.Repository, error)
- func (p *Provider) ListOrganizationRepos(ctx context.Context, org string) ([]*provider.Repository, error)
- func (p *Provider) ListOrganizations(ctx context.Context) ([]*provider.Organization, error)
- func (p *Provider) ListUserRepos(ctx context.Context, user string) ([]*provider.Repository, error)
- func (p *Provider) Name() string
- func (p *Provider) SetToken(token string) error
- func (p *Provider) ValidateToken(ctx context.Context) (bool, error)
- type ProviderOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the provider.Provider interface for GitHub.
func NewProvider ¶
NewProvider creates a new GitHub provider.
A non-empty baseURL targets a GitHub Enterprise Server instance. An empty baseURL keeps the default github.com behavior (backward compatible). Invalid non-empty base URLs return an error (fail-closed; no silent fallback).
func NewProviderWithOptions ¶
func NewProviderWithOptions(opts ProviderOptions) (*Provider, error)
NewProviderWithOptions creates a new GitHub provider with custom options.
func (*Provider) BaseURL ¶
BaseURL returns the configured Enterprise base URL, or "" for github.com.
func (*Provider) CreatePullRequest ¶
func (p *Provider) CreatePullRequest(ctx context.Context, in provider.CreatePullRequestInput) (*provider.PullRequest, error)
CreatePullRequest creates a GitHub pull request. Reviewers and labels are applied after create when supplied.
func (*Provider) FindPullRequest ¶
func (p *Provider) FindPullRequest(ctx context.Context, owner, repo, head, base string) (*provider.PullRequest, error)
FindPullRequest returns the open PR for head/base, or ErrPullRequestNotFound.
func (*Provider) GetRateLimit ¶
GetRateLimit returns current rate limit status.
func (*Provider) GetRepository ¶
func (p *Provider) GetRepository(ctx context.Context, owner, repo string) (*provider.Repository, error)
GetRepository gets a single repository from GitHub.
func (*Provider) ListOrganizationRepos ¶
func (p *Provider) ListOrganizationRepos(ctx context.Context, org string) ([]*provider.Repository, error)
ListOrganizationRepos lists all repositories in a GitHub organization.
func (*Provider) ListOrganizations ¶
ListOrganizations lists organizations the authenticated user belongs to.
func (*Provider) ListUserRepos ¶
ListUserRepos lists all repositories for a user.
type ProviderOptions ¶
type ProviderOptions struct {
Token string
BaseURL string // GitHub Enterprise Server URL; empty for github.com
}
ProviderOptions configures the GitHub Provider.