client

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 16 Imported by: 0

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

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

func NewAppClient(appID, installationID int64, privateKeyPEM []byte, org string) (*Client, error)

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

func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)

Do executes an HTTP request with authentication. ensures token is valid before executing request.

func (*Client) GetAppSlug

func (c *Client) GetAppSlug(ctx context.Context) (string, error)

GetAppSlug fetches the GitHub App slug identifier. used to detect changes made by the app itself. requires JWT authentication (not installation token).

func (*Client) GetClient

func (c *Client) GetClient() *github.Client

GetClient returns the underlying go-github client.

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) GetOrg

func (c *Client) GetOrg() string

GetOrg returns the GitHub organization name.

func (*Client) GetTeamMembers

func (c *Client) GetTeamMembers(ctx context.Context, teamSlug string) ([]string, error)

GetTeamMembers returns GitHub usernames of all team members. paginates through all results to handle large teams.

func (*Client) IsExternalCollaborator

func (c *Client) IsExternalCollaborator(ctx context.Context, username string) (bool, error)

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

func (c *Client) ListOrgMembers(ctx context.Context) ([]string, error)

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.

Jump to

Keyboard shortcuts

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