Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrGhNotInstalled = errors.New("the GitHub CLI (gh) is required but not installed; install it from https://cli.github.com/ and run 'gh auth login'")
ErrGhNotInstalled indicates the gh CLI is not in PATH.
Functions ¶
This section is empty.
Types ¶
type CommandRunner ¶
CommandRunner executes external commands. Swappable for testing.
type ErrNoToken ¶
type ErrNoToken struct {
Domain string
}
ErrNoToken indicates no token could be resolved for a domain.
func (*ErrNoToken) Error ¶
func (e *ErrNoToken) Error() string
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider resolves and caches GitHub tokens for the process lifetime.
func NewProvider ¶
func NewProvider() *Provider
NewProvider creates a Provider with the default command runner.
func NewProviderWithRunner ¶
func NewProviderWithRunner(runner CommandRunner) *Provider
NewProviderWithRunner creates a Provider with a custom command runner (for testing).
func (*Provider) DetectToken ¶
DetectToken resolves a token for the given domain.
Resolution order:
- GITHUB_TOKEN env var — used for ALL domains, including GitHub Enterprise.
- gh auth token --hostname <domain> — domain-specific token from gh CLI.
GITHUB_TOKEN intentionally applies to every domain, not just github.com. This differs from the gh CLI itself, which uses GH_ENTERPRISE_TOKEN for GHE. The rationale: work delegates auth to gh and treats GITHUB_TOKEN as a universal override for CI/CD and automation. Users needing per-domain tokens should use gh auth login --hostname <domain> for each host instead of the env var.
Results are cached in memory for the process lifetime.
type Token ¶
type Token struct {
Value string
Source TokenSource
}
Token holds a resolved token and its source.
type TokenSource ¶
type TokenSource string
TokenSource describes where a token was resolved from.
const ( TokenSourceEnv TokenSource = "GITHUB_TOKEN" TokenSourceGhCLI TokenSource = "gh" )