Documentation
¶
Overview ¶
Package client provides a GitHub API client with App authentication. Handles JWT generation, installation token management, PR compliance checking, and team membership synchronization.
Index ¶
- type Client
- func (c *Client) CheckPRCompliance(ctx context.Context, owner, repo string, prNumber int) (*domain.PRComplianceResult, error)
- func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) GetAppSlug(ctx context.Context) (string, error)
- func (c *Client) GetClient() *github.Client
- func (c *Client) GetOrCreateTeam(ctx context.Context, teamName, privacy string) (*github.Team, error)
- func (c *Client) GetOrg() string
- func (c *Client) GetTeamMembers(ctx context.Context, teamSlug string) ([]string, error)
- func (c *Client) IsExternalCollaborator(ctx context.Context, username string) (bool, error)
- func (c *Client) ListOrgMembers(ctx context.Context) ([]string, error)
- func (c *Client) ListSecurityAlerts(ctx context.Context, minAgeDays int, minSeverity string) (*domain.SecurityAlertsReport, error)
- func (c *Client) SyncTeamMembers(ctx context.Context, teamSlug string, desiredMembers []string, ...) (*domain.TeamSyncResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the GitHub API client with App authentication. automatically refreshes installation tokens before expiry. implements domain.GitHubClient.
func NewAppClient ¶
NewAppClient creates a GitHub App client with default base URL.
func NewAppClientWithBaseURL ¶
func NewAppClientWithBaseURL(appID, installationID int64, privateKeyPEM []byte, org, baseURL string) (*Client, error)
NewAppClientWithBaseURL creates a GitHub App client with custom base URL. supports GitHub Enterprise Server instances.
func (*Client) CheckPRCompliance ¶
func (c *Client) CheckPRCompliance(ctx context.Context, owner, repo string, prNumber int) (*domain.PRComplianceResult, error)
CheckPRCompliance verifies if a merged PR met branch protection requirements. checks review requirements, status checks, and user bypass permissions.
func (*Client) Do ¶
Do executes an HTTP request with authentication. ensures token is valid before executing request.
func (*Client) GetAppSlug ¶
GetAppSlug fetches the GitHub App slug identifier. used to detect changes made by the app itself. requires JWT authentication (not installation token).
func (*Client) GetOrCreateTeam ¶
func (c *Client) GetOrCreateTeam(ctx context.Context, teamName, privacy string) (*github.Team, error)
GetOrCreateTeam fetches an existing team by slug or creates it if missing.
func (*Client) GetTeamMembers ¶
GetTeamMembers returns GitHub usernames of all team members. paginates through all results to handle large teams.
func (*Client) IsExternalCollaborator ¶
IsExternalCollaborator checks if a user is an outside collaborator rather than an organization member. returns true if user is not a full org member.
func (*Client) ListOrgMembers ¶
ListOrgMembers returns all organization members excluding external collaborators.
func (*Client) ListSecurityAlerts ¶ added in v0.22.0
func (c *Client) ListSecurityAlerts(ctx context.Context, minAgeDays int, minSeverity string) (*domain.SecurityAlertsReport, error)
ListSecurityAlerts fetches open security alerts across the org that are older than minAgeDays and at or above minSeverity. covers dependabot, code scanning, and secret scanning alerts.
func (*Client) SyncTeamMembers ¶
func (c *Client) SyncTeamMembers(ctx context.Context, teamSlug string, desiredMembers []string, safetyThreshold float64) (*domain.TeamSyncResult, error)
SyncTeamMembers adds and removes members to match desired state. collects errors for individual operations but continues processing. skips removal of external collaborators (outside org members). applies safety threshold to prevent mass removal during outages.