Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigExists(configPath string) bool
- func OutputJSON(w io.Writer, apps []GitHubApp) error
- func OutputYAML(w io.Writer, apps []GitHubApp) error
- type Config
- func (c *Config) AddOrUpdateApp(app *GitHubApp)
- func (c *Config) AddOrUpdatePAT(pat *PersonalAccessToken)
- func (c *Config) GetApp(appID int64) (*GitHubApp, error)
- func (c *Config) GetByPriority() []GitHubApp
- func (c *Config) RemoveApp(appID int64) bool
- func (c *Config) RemovePAT(name string) bool
- func (c *Config) Save() error
- func (c *Config) Validate() error
- type GitHubApp
- func (app *GitHubApp) DeletePrivateKey(secretMgr *secrets.Manager) error
- func (app *GitHubApp) GetPrivateKey(secretMgr *secrets.Manager) (string, error)
- func (app *GitHubApp) HasPrivateKey(secretMgr *secrets.Manager) bool
- func (app *GitHubApp) SetPrivateKey(secretMgr *secrets.Manager, privateKey string) (secrets.StorageBackend, error)
- func (g *GitHubApp) Validate() error
- type InstallationScope
- type Loader
- type PersonalAccessToken
- func (p *PersonalAccessToken) DeletePAT(secretMgr *secrets.Manager) error
- func (p *PersonalAccessToken) GetPAT(secretMgr *secrets.Manager) (string, error)
- func (p *PersonalAccessToken) SetPAT(secretMgr *secrets.Manager, token string) (secrets.StorageBackend, error)
- func (p *PersonalAccessToken) Validate() error
- type PrivateKeySource
- type RepositoryInfo
Constants ¶
const CurrentConfigVersion = "1"
CurrentConfigVersion is the latest configuration schema version
Variables ¶
var ( ErrConfigNotExists = errors.New("configuration file not found: ") ErrConfigInvalid = errors.New("invalid configuration: ") ErrConfigUnreadable = errors.New("failed to read configuration file: ") ErrConfigUnparsable = errors.New("failed to parse configuration: ") )
Common errors returned by the loader
var (
ErrNoGitHubAppDefined = errors.New("at least one github_app or pat is required")
)
Common errors returned by config
Functions ¶
func ConfigExists ¶
ConfigExists checks if a configuration file exists at the given path
func OutputJSON ¶
OutputJSON outputs apps as JSON
Types ¶
type Config ¶
type Config struct {
Version string `yaml:"version" json:"version"`
GitHubApps []GitHubApp `yaml:"github_apps" json:"github_apps"`
PATs []PersonalAccessToken `yaml:"pats,omitempty" json:"pats,omitempty"`
}
Config represents the GitHub App authentication configuration
func LoadOrCreate ¶
LoadOrCreate loads existing configuration or creates a new one
func (*Config) AddOrUpdateApp ¶
AddOrUpdateApp adds a new app or updates an existing one
func (*Config) AddOrUpdatePAT ¶
func (c *Config) AddOrUpdatePAT(pat *PersonalAccessToken)
AddOrUpdatePAT adds a new PAT or updates an existing one
func (*Config) GetByPriority ¶
GetByPriority returns GitHub Apps sorted by priority (highest first)
type GitHubApp ¶
type GitHubApp struct {
Name string `yaml:"name" json:"name"`
AppID int64 `yaml:"app_id" json:"app_id"`
InstallationID int64 `yaml:"installation_id" json:"installation_id"`
PrivateKeyPath string `yaml:"private_key_path,omitempty" json:"private_key_path,omitempty"`
PrivateKeySource PrivateKeySource `yaml:"private_key_source,omitempty" json:"private_key_source,omitempty"`
Patterns []string `yaml:"patterns" json:"patterns"`
Priority int `yaml:"priority" json:"priority"` // Deprecated: Ignored in favor of longest prefix
Scope *InstallationScope `yaml:"scope,omitempty" json:"scope,omitempty"`
}
GitHubApp represents a single GitHub App configuration
func (*GitHubApp) DeletePrivateKey ¶
DeletePrivateKey removes the private key from secure storage
func (*GitHubApp) GetPrivateKey ¶
GetPrivateKey retrieves the private key from the appropriate source based on the PrivateKeySource configuration
func (*GitHubApp) HasPrivateKey ¶
HasPrivateKey checks if the app has a private key configured
func (*GitHubApp) SetPrivateKey ¶
func (app *GitHubApp) SetPrivateKey(secretMgr *secrets.Manager, privateKey string) (secrets.StorageBackend, error)
SetPrivateKey stores the private key securely It attempts to use keyring first, falling back to filesystem if unavailable
type InstallationScope ¶
type InstallationScope struct {
// Core scope information
RepositorySelection string `yaml:"repository_selection" json:"repository_selection"` // "all" or "selected"
AccountLogin string `yaml:"account_login" json:"account_login"` // org or user name
AccountType string `yaml:"account_type" json:"account_type"` // "Organization" or "User"
// Repository list (only populated if repository_selection == "selected")
Repositories []RepositoryInfo `yaml:"repositories,omitempty" json:"repositories,omitempty"`
// Cache metadata
LastFetched time.Time `yaml:"last_fetched" json:"last_fetched"`
LastUpdated time.Time `yaml:"last_updated" json:"last_updated"` // From GitHub API
CacheExpiry time.Time `yaml:"cache_expiry" json:"cache_expiry"`
}
InstallationScope represents cached GitHub App installation scope information
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader handles loading GitHub App configurations from files
func NewDefaultLoader ¶
func NewDefaultLoader() *Loader
NewDefaultLoader creates a loader with the default configuration path
func (*Loader) GetConfigPath ¶
GetConfigPath returns the configuration path that would be used
func (*Loader) LoadWithFallback ¶
LoadWithFallback loads configuration, returns nil if file doesn't exist (no error)
type PersonalAccessToken ¶
type PersonalAccessToken struct {
Name string `yaml:"name" json:"name"`
TokenSource PrivateKeySource `yaml:"private_key_source,omitempty" json:"private_key_source,omitempty"`
Patterns []string `yaml:"patterns" json:"patterns"`
Priority int `yaml:"priority" json:"priority"`
// Username for HTTP basic auth (optional, defaults to "x-access-token" for GitHub)
Username string `yaml:"username,omitempty" json:"username,omitempty"`
}
func (*PersonalAccessToken) DeletePAT ¶
func (p *PersonalAccessToken) DeletePAT(secretMgr *secrets.Manager) error
DeletePAT removes the PAT from secure storage
func (*PersonalAccessToken) GetPAT ¶
func (p *PersonalAccessToken) GetPAT(secretMgr *secrets.Manager) (string, error)
GetPAT retrieves the Personal Access Token from the appropriate source
func (*PersonalAccessToken) SetPAT ¶
func (p *PersonalAccessToken) SetPAT(secretMgr *secrets.Manager, token string) (secrets.StorageBackend, error)
SetPAT stores the Personal Access Token securely
func (*PersonalAccessToken) Validate ¶
func (p *PersonalAccessToken) Validate() error
type PrivateKeySource ¶
type PrivateKeySource string
PrivateKeySource indicates where the private key is stored
const ( // PrivateKeySourceKeyring indicates the key is in the OS keyring PrivateKeySourceKeyring PrivateKeySource = "keyring" // PrivateKeySourceFilesystem indicates the key is in a file PrivateKeySourceFilesystem PrivateKeySource = "filesystem" // PrivateKeySourceInline indicates the key was provided inline (legacy) PrivateKeySourceInline PrivateKeySource = "inline" )
type RepositoryInfo ¶
type RepositoryInfo struct {
FullName string `yaml:"full_name" json:"full_name"` // "owner/repo"
Private bool `yaml:"private" json:"private"`
}
RepositoryInfo represents a cached repository