github

package
v0.0.0-...-1ed64df Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 10 Imported by: 1

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

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

func NewProvider(token, baseURL string) (*Provider, error)

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

func (p *Provider) BaseURL() string

BaseURL returns the configured Enterprise base URL, or "" for github.com.

func (*Provider) CreatePullRequest

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

func (p *Provider) GetRateLimit(ctx context.Context) (*provider.RateLimit, error)

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

func (p *Provider) ListOrganizations(ctx context.Context) ([]*provider.Organization, error)

ListOrganizations lists organizations the authenticated user belongs to.

func (*Provider) ListUserRepos

func (p *Provider) ListUserRepos(ctx context.Context, user string) ([]*provider.Repository, error)

ListUserRepos lists all repositories for a user.

func (*Provider) Name

func (p *Provider) Name() string

Name returns the provider name.

func (*Provider) SetToken

func (p *Provider) SetToken(token string) error

SetToken sets the authentication token, preserving the configured base URL.

func (*Provider) ValidateToken

func (p *Provider) ValidateToken(ctx context.Context) (bool, error)

ValidateToken validates the current token.

type ProviderOptions

type ProviderOptions struct {
	Token   string
	BaseURL string // GitHub Enterprise Server URL; empty for github.com
}

ProviderOptions configures the GitHub Provider.

Jump to

Keyboard shortcuts

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