profile

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

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 Label

func Label(p config.ProfileConfig) string

Label renders the profile for the UI header.

func Resolve

func Resolve(target, flagProfile string, cfg config.Config, env Env) (config.ProfileConfig, error)

Resolve returns the profile that owns target. Precedence, first match wins:

  1. --profile flag
  2. declared profile whose Root is the longest path prefix of target
  3. .glab-cli directory or .envrc export found by walking up from target
  4. ambient GLAB_CONFIG_DIR / GH_CONFIG_DIR
  5. 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
}

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

func Accounts(cfg config.Config, home, cwd string) []Account

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.

func (Account) Location

func (a Account) Location() string

Location is the directory that identifies the account, for display.

func (Account) Provider

func (a Account) Provider() string

Provider names the CLIs this account is configured for.

type Env

type Env func(key string) string

Env abstracts environment lookup so tests need not mutate the process env.

Jump to

Keyboard shortcuts

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