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 ¶
- Variables
- func RateLimitError(err error) error
- func ValidRepositoryName(value string) bool
- type Client
- func (c *Client) API(ctx context.Context) (*gh.Client, error)
- func (c *Client) Authenticate(ctx context.Context) error
- func (c *Client) AuthenticatedAPI(ctx context.Context) (*gh.Client, error)
- func (c *Client) AuthenticatedUser(ctx context.Context) (string, error)
- func (c *Client) CredentialSource() CredentialSource
- type Config
- type CredentialSource
- type DeviceFlow
- type SystemCredentials
- type Token
- type TokenSource
- type TokenSourceFunc
Constants ¶
This section is empty.
Variables ¶
var ErrAuthentication = forge.ErrAuthentication
var ErrNoCredentials = fmt.Errorf("%w: no credential available", ErrAuthentication)
ErrNoCredentials permits anonymous public reads; invalid or inaccessible credentials do not.
Functions ¶
func RateLimitError ¶
func ValidRepositoryName ¶
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 ¶
API uses available credentials for public reads, allowing anonymous reads only when none exist.
func (*Client) AuthenticatedAPI ¶
AuthenticatedAPI shares one initialized credential and SDK client between adapters.
func (*Client) AuthenticatedUser ¶
func (*Client) CredentialSource ¶
func (c *Client) CredentialSource() CredentialSource
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 ¶
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
}
type Token ¶
type Token struct {
Secret string `json:"-"`
Source CredentialSource `json:"source"`
}