Documentation
¶
Overview ¶
Package github implements the GitHub adapter for the github capability.
Index ¶
- Constants
- func Register(app string, svc Service) error
- type Adapter
- func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
- func (a *Adapter) GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, ...) ([]byte, error)
- func (a *Adapter) GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)
- func (a *Adapter) GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
- func (a *Adapter) GetUser(ctx context.Context) (*capability.ForgeUser, error)
- func (a *Adapter) GetUserByLogin(ctx context.Context, login string) (*capability.ForgeUser, error)
- func (a *Adapter) HealthCheck(ctx context.Context) (bool, error)
- func (a *Adapter) ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
- func (a *Adapter) ListNotifications(ctx context.Context, q *PageQuery) (*capability.ListResult[capability.Notification], error)
- func (a *Adapter) ListReleases(ctx context.Context, owner, repo string, q *PageQuery) (*capability.ListResult[capability.Release], error)
- func (a *Adapter) SetCursorSecret(secret []byte)
- type GithubWebhook
- type ListIssuesQuery
- type PageQuery
- type Service
Constants ¶
const ( OpGetUser = "get_user" OpGetUserByLogin = "get_user_by_login" OpGetRepo = "get_repo" OpListIssues = "list_issues" OpGetIssue = "get_issue" OpGetCommitDiff = "get_commit_diff" OpGetFileContent = "get_file_content" OpListNotifications = "list_notifications" OpListReleases = "list_releases" OpHealth = "health" )
const Capability hub.CapabilityType = hub.CapGithub
Capability is the GitHub capability type constant.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements Service using the GitHub provider client.
func (*Adapter) GetCommitDiff ¶
func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
GetCommitDiff returns the diff for a specific commit from the GitHub API.
func (*Adapter) GetFileContent ¶
func (a *Adapter) GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)
GetFileContent returns file content at a specific commit with line range from the GitHub API.
func (*Adapter) GetIssue ¶
func (a *Adapter) GetIssue(ctx context.Context, owner, repo string, index int64) (*capability.ForgeIssue, error)
GetIssue returns a single issue by owner, repo name, and index. Lists issues for the owner and filters by repository name and index.
func (*Adapter) GetRepo ¶
GetRepo returns a single repository by owner and name from the GitHub API.
func (*Adapter) GetUserByLogin ¶
GetUserByLogin returns a GitHub user's profile by login name from the GitHub API.
func (*Adapter) HealthCheck ¶
HealthCheck reports whether the GitHub backend is reachable by querying the authenticated user.
func (*Adapter) ListIssues ¶
func (a *Adapter) ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
ListIssues returns a paginated list of issues for the given owner from the GitHub API.
func (*Adapter) ListNotifications ¶
func (a *Adapter) ListNotifications(ctx context.Context, q *PageQuery) (*capability.ListResult[capability.Notification], error)
ListNotifications returns the authenticated user's notifications from the GitHub API.
func (*Adapter) ListReleases ¶
func (a *Adapter) ListReleases(ctx context.Context, owner, repo string, q *PageQuery) (*capability.ListResult[capability.Release], error)
ListReleases returns releases for a repository from the GitHub API.
func (*Adapter) SetCursorSecret ¶
SetCursorSecret sets the cursor signing secret (for testing).
type GithubWebhook ¶
type GithubWebhook struct {
// contains filtered or unexported fields
}
GithubWebhook implements capability.WebhookConverter for the GitHub provider. It validates HMAC-SHA256 signature and converts GitHub webhook payloads into DataEvent records.
func NewGithubWebhook ¶
func NewGithubWebhook() *GithubWebhook
NewGithubWebhook creates a GithubWebhook that reads the HMAC secret from the github provider config at verification time.
func (*GithubWebhook) Convert ¶
Convert transforms the raw GitHub webhook body into DataEvent records. Event type is determined by the X-GitHub-Event header:
"push" — emitted as forge.push "issues" — emitted as forge.issue.<action>
Unsupported event types and actions are logged and yield no events.
func (*GithubWebhook) VerifySignature ¶
func (w *GithubWebhook) VerifySignature(headers map[string]string, body []byte) error
VerifySignature validates the HMAC-SHA256 signature from the X-Hub-Signature-256 header. GitHub signs the raw body with the configured webhook secret using SHA-256, and sends it as "sha256=<hex digest>".
func (*GithubWebhook) WebhookPath ¶
func (*GithubWebhook) WebhookPath() string
WebhookPath returns the URL path that receives webhook events from GitHub. The full URL is /webhook/provider/github/events.
type ListIssuesQuery ¶
type ListIssuesQuery = capability.GithubListIssuesQuery
ListIssuesQuery wraps pagination and filtering for listing issues.
type PageQuery ¶
type PageQuery = capability.GithubPageQuery
PageQuery wraps pagination for list operations.
type Service ¶
type Service interface {
GetUser(ctx context.Context) (*capability.ForgeUser, error)
GetUserByLogin(ctx context.Context, login string) (*capability.ForgeUser, error)
GetRepo(ctx context.Context, owner, repo string) (*capability.ForgeRepo, error)
ListIssues(ctx context.Context, owner string, q *ListIssuesQuery) (*capability.ListResult[capability.ForgeIssue], error)
GetIssue(ctx context.Context, owner, repo string, number int64) (*capability.ForgeIssue, error)
GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*capability.ForgeCommitDiff, error)
GetFileContent(ctx context.Context, owner, repo, commitID, filePath string, lineStart, lineCount int) ([]byte, error)
ListNotifications(ctx context.Context, q *PageQuery) (*capability.ListResult[capability.Notification], error)
ListReleases(ctx context.Context, owner, repo string, q *PageQuery) (*capability.ListResult[capability.Release], error)
HealthCheck(ctx context.Context) (bool, error)
}
Service defines the GitHub capability contract.
func NewWithClient ¶
func NewWithClient(c client) Service
NewWithClient creates an Adapter with a specific client, useful for testing.