Documentation
¶
Index ¶
- func FormatContainerID(owner, repo string) string
- func ParseContainerID(containerID string) (owner, repo string, err error)
- type Builder
- func (b *Builder) Build(ctx context.Context, tokenProvider driven.TokenProvider, containerID string) (driven.Connector, error)
- func (b *Builder) OAuthConfig() *driven.OAuthConfig
- func (b *Builder) SupportsContainerSelection() bool
- func (b *Builder) SupportsOAuth() bool
- func (b *Builder) Type() domain.ProviderType
- type Client
- func (c *Client) GetFileContent(ctx context.Context, owner, repo, path string) (*FileContent, error)
- func (c *Client) GetRepository(ctx context.Context, owner, repo string) (*Repository, error)
- func (c *Client) GetTree(ctx context.Context, owner, repo, sha string) ([]*TreeEntry, error)
- func (c *Client) GetUser(ctx context.Context) (*User, error)
- func (c *Client) ListAccessibleRepos(ctx context.Context, cursor string) (*ListReposResponse, error)
- func (c *Client) ListIssues(ctx context.Context, owner, repo string, since *time.Time, cursor string) ([]*Issue, string, error)
- func (c *Client) ListPullRequests(ctx context.Context, owner, repo string, cursor string) ([]*PullRequest, string, error)
- func (c *Client) ValidateRepoAccess(ctx context.Context, owner, repo string) error
- type Commit
- type CommitAuthor
- type Config
- type Connector
- func (c *Connector) FetchChanges(ctx context.Context, source *domain.Source, cursor string) ([]*domain.Change, string, error)
- func (c *Connector) FetchDocument(ctx context.Context, source *domain.Source, externalID string) (*domain.Document, string, error)
- func (c *Connector) TestConnection(ctx context.Context, source *domain.Source) error
- func (c *Connector) Type() domain.ProviderType
- func (c *Connector) ValidateConfig(config domain.SourceConfig) error
- type ContainerLister
- type ContainerListerFactory
- type FileContent
- type Issue
- type Label
- type ListReposResponse
- type OAuthConfig
- type OAuthHandler
- func (h *OAuthHandler) BuildAuthURL(clientID, redirectURI, state, codeChallenge string, scopes []string) string
- func (h *OAuthHandler) DefaultConfig() connectors.OAuthDefaults
- func (h *OAuthHandler) ExchangeCode(ctx context.Context, ...) (*driven.OAuthToken, error)
- func (h *OAuthHandler) GetUserInfo(ctx context.Context, accessToken string) (*driven.OAuthUserInfo, error)
- func (h *OAuthHandler) RefreshToken(ctx context.Context, clientID, clientSecret, refreshToken string) (*driven.OAuthToken, error)
- type PRBranch
- type PullRequest
- type Repository
- type RepositoryOwner
- type TokenRefresher
- type TreeEntry
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatContainerID ¶
FormatContainerID formats owner and repo into a container ID.
func ParseContainerID ¶
ParseContainerID parses a container ID into owner and repo. Format: "owner/repo"
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder creates GitHub connectors.
func NewBuilderWithConfig ¶
NewBuilderWithConfig creates a builder with custom configuration.
func (*Builder) Build ¶
func (b *Builder) Build(ctx context.Context, tokenProvider driven.TokenProvider, containerID string) (driven.Connector, error)
Build creates a GitHub connector scoped to a specific repository. containerID format: "owner/repo"
func (*Builder) OAuthConfig ¶
func (b *Builder) OAuthConfig() *driven.OAuthConfig
OAuthConfig returns OAuth configuration for GitHub.
func (*Builder) SupportsContainerSelection ¶
SupportsContainerSelection returns true - GitHub supports repository selection.
func (*Builder) SupportsOAuth ¶
SupportsOAuth returns true - GitHub supports OAuth2.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client provides GitHub API operations.
func NewClient ¶
func NewClient(tokenProvider driven.TokenProvider, baseURL string) *Client
NewClient creates a new GitHub API client.
func (*Client) GetFileContent ¶
func (c *Client) GetFileContent(ctx context.Context, owner, repo, path string) (*FileContent, error)
GetFileContent gets the content of a file.
func (*Client) GetRepository ¶
GetRepository gets repository information.
func (*Client) ListAccessibleRepos ¶
func (c *Client) ListAccessibleRepos(ctx context.Context, cursor string) (*ListReposResponse, error)
ListAccessibleRepos lists all repositories accessible to the authenticated user.
func (*Client) ListIssues ¶
func (c *Client) ListIssues(ctx context.Context, owner, repo string, since *time.Time, cursor string) ([]*Issue, string, error)
ListIssues lists issues for a repository.
func (*Client) ListPullRequests ¶
func (c *Client) ListPullRequests(ctx context.Context, owner, repo string, cursor string) ([]*PullRequest, string, error)
ListPullRequests lists pull requests for a repository.
type Commit ¶
type Commit struct {
SHA string `json:"sha"`
Message string `json:"message"`
Author *CommitAuthor `json:"author"`
Date time.Time `json:"date"`
}
Commit represents a GitHub commit.
type CommitAuthor ¶
type CommitAuthor struct {
Name string `json:"name"`
Email string `json:"email"`
Date time.Time `json:"date"`
}
CommitAuthor represents commit author info.
type Config ¶
type Config struct {
// APIBaseURL is the base URL for GitHub API.
// Defaults to https://api.github.com for github.com.
// For GitHub Enterprise, use https://<hostname>/api/v3
APIBaseURL string
// PerPage is the number of items to fetch per page.
// Maximum is 100.
PerPage int
// MaxRetries is the maximum number of retry attempts for rate-limited requests.
MaxRetries int
// IncludeFiles enables indexing of repository files.
IncludeFiles bool
// IncludeIssues enables indexing of issues.
IncludeIssues bool
// IncludePRs enables indexing of pull requests.
IncludePRs bool
// IncludeDiscussions enables indexing of discussions.
IncludeDiscussions bool
// IncludeWiki enables indexing of wiki pages.
IncludeWiki bool
// FileExtensions is a list of file extensions to index.
// Empty means all text-based files.
FileExtensions []string
// ExcludePaths is a list of path patterns to exclude.
ExcludePaths []string
// MaxFileSize is the maximum file size in bytes to fetch.
// Default is 1MB.
MaxFileSize int64
// Concurrency is the number of concurrent file content fetches.
// Default is 10.
Concurrency int
}
Config contains configuration for the GitHub connector.
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns the default GitHub connector configuration.
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
Connector fetches documents from a single GitHub repository.
func NewConnector ¶
func NewConnector(tokenProvider driven.TokenProvider, owner, repo string, config *Config) *Connector
NewConnector creates a GitHub connector scoped to a specific repository.
func (*Connector) FetchChanges ¶
func (c *Connector) FetchChanges(ctx context.Context, source *domain.Source, cursor string) ([]*domain.Change, string, error)
FetchChanges fetches document changes from the repository. For initial sync (empty cursor), it fetches all content. For incremental sync, it fetches changes since the cursor timestamp.
func (*Connector) FetchDocument ¶
func (c *Connector) FetchDocument(ctx context.Context, source *domain.Source, externalID string) (*domain.Document, string, error)
FetchDocument fetches a single document by external ID.
func (*Connector) TestConnection ¶
TestConnection tests the connection to the repository.
func (*Connector) Type ¶
func (c *Connector) Type() domain.ProviderType
Type returns the provider type.
func (*Connector) ValidateConfig ¶
func (c *Connector) ValidateConfig(config domain.SourceConfig) error
ValidateConfig validates source configuration.
type ContainerLister ¶
type ContainerLister struct {
// contains filtered or unexported fields
}
ContainerLister lists GitHub repositories accessible with an installation's credentials.
func NewContainerLister ¶
func NewContainerLister(tokenProvider driven.TokenProvider, baseURL string) *ContainerLister
NewContainerLister creates a ContainerLister with the given token provider.
func (*ContainerLister) ListContainers ¶
func (l *ContainerLister) ListContainers(ctx context.Context, cursor string) ([]*driven.Container, string, error)
ListContainers lists all repositories accessible to the authenticated user. Returns repositories as containers in the format "owner/repo".
type ContainerListerFactory ¶
type ContainerListerFactory struct {
// contains filtered or unexported fields
}
ContainerListerFactory creates ContainerListers for GitHub installations.
func NewContainerListerFactory ¶
func NewContainerListerFactory( installationStore driven.ConnectionStore, tokenFactory driven.TokenProviderFactory, baseURL string, ) *ContainerListerFactory
NewContainerListerFactory creates a factory for GitHub container listers.
func (*ContainerListerFactory) Create ¶
func (f *ContainerListerFactory) Create(ctx context.Context, installationID string) (driven.ContainerLister, error)
Create creates a ContainerLister for a GitHub installation.
type FileContent ¶
type FileContent struct {
Name string `json:"name"`
Path string `json:"path"`
SHA string `json:"sha"`
Size int64 `json:"size"`
Content string `json:"content"`
Encoding string `json:"encoding"`
HTMLURL string `json:"html_url"`
}
FileContent represents file content from GitHub.
type Issue ¶
type Issue struct {
ID int64 `json:"id"`
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
User *User `json:"user"`
Labels []Label `json:"labels"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ClosedAt *time.Time `json:"closed_at"`
Comments int `json:"comments"`
IsPR bool `json:"-"` // Set based on pull_request field presence
}
Issue represents a GitHub issue.
type ListReposResponse ¶
type ListReposResponse struct {
Repos []*Repository
NextCursor string
}
ListReposResponse is the response from listing repositories.
type OAuthConfig ¶
OAuthConfig contains OAuth configuration for GitHub.
type OAuthHandler ¶
type OAuthHandler struct {
// contains filtered or unexported fields
}
OAuthHandler handles OAuth operations for GitHub.
func NewOAuthHandler ¶
func NewOAuthHandler() *OAuthHandler
NewOAuthHandler creates a new GitHub OAuth handler.
func (*OAuthHandler) BuildAuthURL ¶
func (h *OAuthHandler) BuildAuthURL(clientID, redirectURI, state, codeChallenge string, scopes []string) string
BuildAuthURL constructs the GitHub OAuth authorization URL.
func (*OAuthHandler) DefaultConfig ¶
func (h *OAuthHandler) DefaultConfig() connectors.OAuthDefaults
DefaultConfig returns GitHub's default OAuth configuration.
func (*OAuthHandler) ExchangeCode ¶
func (h *OAuthHandler) ExchangeCode(ctx context.Context, clientID, clientSecret, code, redirectURI, codeVerifier string) (*driven.OAuthToken, error)
ExchangeCode exchanges an authorization code for tokens.
func (*OAuthHandler) GetUserInfo ¶
func (h *OAuthHandler) GetUserInfo(ctx context.Context, accessToken string) (*driven.OAuthUserInfo, error)
GetUserInfo fetches the authenticated user's information.
func (*OAuthHandler) RefreshToken ¶
func (h *OAuthHandler) RefreshToken(ctx context.Context, clientID, clientSecret, refreshToken string) (*driven.OAuthToken, error)
RefreshToken refreshes an expired access token. Note: GitHub OAuth tokens don't expire by default, but GitHub Apps use refresh tokens.
type PullRequest ¶
type PullRequest struct {
ID int64 `json:"id"`
Number int `json:"number"`
Title string `json:"title"`
Body string `json:"body"`
State string `json:"state"`
HTMLURL string `json:"html_url"`
User *User `json:"user"`
Head *PRBranch `json:"head"`
Base *PRBranch `json:"base"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
MergedAt *time.Time `json:"merged_at"`
ClosedAt *time.Time `json:"closed_at"`
}
PullRequest represents a GitHub pull request.
type Repository ¶
type Repository struct {
ID int64 `json:"id"`
Owner string `json:"-"` // Populated from FullName, not JSON
OwnerInfo *RepositoryOwner `json:"owner"`
Name string `json:"name"`
FullName string `json:"full_name"`
Description string `json:"description"`
Private bool `json:"private"`
Archived bool `json:"archived"`
HTMLURL string `json:"html_url"`
DefaultBranch string `json:"default_branch"`
}
Repository represents a GitHub repository.
type RepositoryOwner ¶
RepositoryOwner represents the owner object in GitHub API responses.
type TokenRefresher ¶
type TokenRefresher struct {
// contains filtered or unexported fields
}
TokenRefresher implements driven.TokenRefresher for GitHub.
func NewTokenRefresher ¶
func NewTokenRefresher(clientID, clientSecret string) *TokenRefresher
NewTokenRefresher creates a GitHub token refresher.