github

package
v0.0.0-...-506f4e1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 11 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	GH        *github.Client
	PlainHTTP *http.Client // no Authorization header; for pre-signed S3 URLs

	// OnRateLimit, if set, is called whenever the client hits or proactively
	// avoids a rate limit. Set this before issuing API calls.
	OnRateLimit func(RateLimitEvent)
	// contains filtered or unexported fields
}

Client wraps the go-github client and a plain HTTP client for log downloads.

func NewClient

func NewClient(token string) *Client

NewClient constructs a GitHub API client authenticated with the given token.

func (*Client) CheckPermissions

func (c *Client) CheckPermissions(ctx context.Context, needsOrg bool) error

CheckPermissions validates the token by calling /user and /rate_limit. For PATs it also inspects X-OAuth-Scopes for required scopes. GitHub App installation tokens (ghs_…) return 403 on /user — that is handled gracefully: the check falls back to /rate_limit only and skips scope validation (App tokens have permissions defined in their installation, not OAuth scopes).

func (*Client) DownloadRunLogs

func (c *Client) DownloadRunLogs(ctx context.Context, owner, repo string, runID int64) ([]LogFile, error)

DownloadRunLogs fetches the workflow run logs zip and extracts all .txt files. Returns an empty slice (no error) if logs are unavailable (404).

func (*Client) ListOrgRepos

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

ListOrgRepos returns all repos (full "owner/repo" strings) in the given org. It paginates until all pages are consumed.

func (*Client) ListRunsInWindow

func (c *Client) ListRunsInWindow(ctx context.Context, owner, repo, since, until string) ([]*github.WorkflowRun, error)

ListRunsInWindow returns all workflow runs in [since, until] for the given repo. It paginates until all pages are consumed.

type LogFile

type LogFile struct {
	Name    string
	Content string
}

LogFile holds the name and text content of a single file extracted from the run logs zip.

type RateLimitEvent

type RateLimitEvent struct {
	Remaining int
	ResetAt   time.Time
	Sleeping  bool // true while the client is blocked; false when the pause ends
}

RateLimitEvent describes a rate-limit pause so callers can surface it in a UI.

Jump to

Keyboard shortcuts

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