Documentation
¶
Overview ¶
Package profile resolves which account identity gu should act as.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Resolve ¶
Resolve returns the profile that owns target. Precedence, first match wins:
- --profile flag
- declared profile whose Root is the longest path prefix of target
- .glab-cli directory or .envrc export found by walking up from target
- ambient GLAB_CONFIG_DIR / GH_CONFIG_DIR
- default_profile
"Nothing matched" is not an error: it yields a zero ProfileConfig, meaning gu should let glab and gh use their own default configuration.
Types ¶
type Account ¶
type Account struct {
Name string
GlabConfigDir string
GhConfigDir string
// Declared marks an account that came from config.yaml rather than from
// scanning the disk, so the UI can say which is which.
Declared bool
// CLIDefault marks the fallback account, which names no directory at all:
// glab and gh are left to use whatever they are configured with.
CLIDefault bool
}
Account is one CLI identity available on this machine: the glab and gh configuration directories that belong together, under a name.
A profile is its configuration directory, not its hostname — two accounts routinely share gitlab.com and are told apart only by which directory the CLI is pointed at.
func Accounts ¶
Accounts lists every identity gu can act as: the ones declared in config.yaml, plus every glab or gh configuration directory found on disk.
Discovery is what makes `:ctx` useful without configuration — the accounts are already on the machine, in the directories the CLIs were pointed at, and asking the user to declare them again in a second file would be asking twice. A declared profile still wins on name and on any directory it sets.
func (Account) Config ¶
func (a Account) Config() config.ProfileConfig
Config renders the account as the profile the rest of gu takes.