client

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package client is the GitHub API client. It authenticates as a GitHub App, checks merged pull requests for compliance, syncs team membership, and lists security alerts.

Index

Constants

View Source
const (
	AlertTypeDependabot     = "dependabot"
	AlertTypeCodeScanning   = "code_scanning"
	AlertTypeSecretScanning = "secret_scanning"
)

Alert types in a security alerts report.

Variables

This section is empty.

Functions

func ParsePrivateKey added in v1.0.0

func ParsePrivateKey(privateKeyPEM []byte) (*rsa.PrivateKey, error)

ParsePrivateKey parses a PEM-encoded RSA private key in PKCS#1 or PKCS#8 form. Escaped newlines ("\n"), as found in single-line environment variables, are accepted.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a GitHub API client authenticated as a GitHub App installation. It is safe for concurrent use. Implements domain.GitHubClient.

func New added in v1.0.0

func New(opts Options) (*Client, error)

New creates a Client. It makes no API calls: credentials are exchanged for an installation token on first use and refreshed before they expire.

func (*Client) CheckPRCompliance

func (c *Client) CheckPRCompliance(ctx context.Context, owner, repo string, prNumber int) (*domain.PRComplianceResult, error)

CheckPRCompliance verifies whether a merged PR met the requirements of its base branch: the approving reviews and status checks required by legacy branch protection and by repository rulesets. When it did not, the merger's repository role is recorded as the likely reason it could merge.

func (*Client) GetAppSlug

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

GetAppSlug returns the GitHub App's slug, used to recognize changes the app made itself. It is fetched once and cached.

func (*Client) GetTeamMembers

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

GetTeamMembers returns the logins of all team members.

func (*Client) ListOrgMembers

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

ListOrgMembers returns the logins of all organization members. Outside collaborators are not members, so they are not included.

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 were created more than minAgeDays ago and are at or above minSeverity. It covers dependabot, code scanning, and secret scanning alerts. A source that fails is recorded in the report's errors and the others still run.

func (*Client) ResolveTeam added in v1.0.0

func (c *Client) ResolveTeam(ctx context.Context, name, privacy string, create bool) (string, error)

ResolveTeam returns the slug of the team with the given name, creating the team when it is missing and create is true.

func (*Client) SyncTeamMembers

func (c *Client) SyncTeamMembers(ctx context.Context, teamSlug string, desiredMembers []string, safetyThreshold float64) (*domain.TeamSyncResult, error)

SyncTeamMembers adds and removes members so the team matches desiredMembers. Errors for individual users are collected and the rest continue. Members of child teams and users who are not org members are not removed, and no one is removed if more than safetyThreshold of the team's direct members would be, which guards against an empty or partial member list from Okta.

type Options added in v1.0.0

type Options struct {
	AppID int64
	// InstallationID is the app's installation on Org. When zero, the
	// installation is looked up on first use.
	InstallationID int64
	// PrivateKey is the app's PEM-encoded RSA private key.
	PrivateKey []byte
	Org        string
	// BaseURL is the API base URL, such as https://ghe.example.com/api/v3
	// for GitHub Enterprise Server. Empty means https://api.github.com.
	BaseURL string
	// HTTPClient is the client requests are sent with. Its transport is
	// wrapped to add authentication. Defaults to a client with a timeout.
	HTTPClient *http.Client
}

Options configures a Client.

Jump to

Keyboard shortcuts

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