Documentation
¶
Overview ¶
Package github implements the GitHub adapter for the github capability.
Index ¶
- func New() githubsvc.Service
- func NewWithClient(c client) githubsvc.Service
- type Adapter
- func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*ability.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) (*ability.ForgeIssue, error)
- func (a *Adapter) GetRepo(ctx context.Context, owner, repo string) (*ability.ForgeRepo, error)
- func (a *Adapter) GetUser(ctx context.Context) (*ability.ForgeUser, error)
- func (a *Adapter) GetUserByLogin(ctx context.Context, login string) (*ability.ForgeUser, error)
- func (a *Adapter) ListIssues(ctx context.Context, owner string, q *githubsvc.ListIssuesQuery) (*ability.ListResult[ability.ForgeIssue], error)
- func (a *Adapter) ListNotifications(ctx context.Context, q *githubsvc.PageQuery) (*ability.ListResult[ability.Notification], error)
- func (a *Adapter) ListReleases(ctx context.Context, owner, repo string, q *githubsvc.PageQuery) (*ability.ListResult[ability.Release], error)
- func (a *Adapter) SetCursorSecret(secret []byte)
- type GithubWebhook
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewWithClient ¶
NewWithClient creates an Adapter with a specific client, useful for testing.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements githubsvc.Service using the GitHub provider client.
func (*Adapter) GetCommitDiff ¶
func (a *Adapter) GetCommitDiff(ctx context.Context, owner, repo, commitID string) (*ability.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) (*ability.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) ListIssues ¶
func (a *Adapter) ListIssues(ctx context.Context, owner string, q *githubsvc.ListIssuesQuery) (*ability.ListResult[ability.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 *githubsvc.PageQuery) (*ability.ListResult[ability.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 *githubsvc.PageQuery) (*ability.ListResult[ability.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 ability.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.