github

package
v0.0.0-20260920.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: MIT Imports: 14 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 github supplies the GitHub client and authentication shared by forge and verification adapters.

It selects credentials, constructs go-github clients lazily, implements device authorization and identity checks, and applies redirect and rate-limit handling. The adapters own repository, pull-request, and Actions operations; callers own credential persistence and user interaction.

Index

Constants

This section is empty.

Variables

View Source
var ErrAuthentication = forge.ErrAuthentication
View Source
var ErrNoCredentials = fmt.Errorf("%w: no credential available", ErrAuthentication)

ErrNoCredentials permits anonymous public reads; invalid or inaccessible credentials do not.

Functions

func RateLimitError

func RateLimitError(err error) error

func ValidRepositoryName

func ValidRepositoryName(value string) bool

Types

type Client

type Client struct {
	HTTP        *http.Client
	Config      Config
	Credentials TokenSource
	// contains filtered or unexported fields
}

Configure a Client before its first API operation; it is then safe to share.

func (*Client) API

func (c *Client) API(ctx context.Context) (*gh.Client, error)

API uses available credentials for public reads, allowing anonymous reads only when none exist.

func (*Client) Authenticate

func (c *Client) Authenticate(ctx context.Context) error

func (*Client) AuthenticatedAPI

func (c *Client) AuthenticatedAPI(ctx context.Context) (*gh.Client, error)

AuthenticatedAPI shares one initialized credential and SDK client between adapters.

func (*Client) AuthenticatedUser

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

func (*Client) CredentialSource

func (c *Client) CredentialSource() CredentialSource

type Config

type Config struct {
	BaseURL string
	Token   string
}

type CredentialSource

type CredentialSource string
const (
	SourceExplicit          CredentialSource = "explicit credential"
	SourceGHEnvironment     CredentialSource = "GH_TOKEN"
	SourceGitHubEnvironment CredentialSource = "GITHUB_TOKEN"
	SourceKeychain          CredentialSource = "Dockhand macOS Keychain"
	SourceGitHubCLI         CredentialSource = "GitHub CLI"
)

type DeviceFlow

type DeviceFlow struct {
	HTTP       *http.Client
	Endpoint   oauth2.Endpoint
	APIBaseURL string
}

func (*DeviceFlow) Authorize

func (f *DeviceFlow) Authorize(ctx context.Context, clientID string, present func(credential.DeviceAuthorization) error) (credential.Value, error)

type SystemCredentials

type SystemCredentials struct {
	Store credential.Store
	Key   credential.Key
}

func (SystemCredentials) Token

func (s SystemCredentials) Token(ctx context.Context) (Token, error)

type Token

type Token struct {
	Secret string           `json:"-"`
	Source CredentialSource `json:"source"`
}

type TokenSource

type TokenSource interface {
	Token(context.Context) (Token, error)
}

type TokenSourceFunc

type TokenSourceFunc func(context.Context) (Token, error)

func (TokenSourceFunc) Token

func (f TokenSourceFunc) Token(ctx context.Context) (Token, error)

Jump to

Keyboard shortcuts

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