config

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearStoredCredentials added in v1.1.0

func ClearStoredCredentials() error

ClearStoredCredentials removes config.json and profiles.json (logout).

func Delete

func Delete() error

Delete removes the configuration file.

func DeleteProfile

func DeleteProfile(name string) error

DeleteProfile removes a named profile.

func Dir

func Dir() string

Dir returns the configuration directory path ~/.gitlab-cli/

func FilePath

func FilePath() string

FilePath returns the configuration file path ~/.gitlab-cli/config.json

func IsConfigured

func IsConfigured() bool

IsConfigured reports whether credentials are available (file or env vars).

func ProfileNames

func ProfileNames(pf *ProfilesFile) []string

ProfileNames returns sorted profile names.

func Save

func Save(cfg *Config) error

Save writes config.json and updates the default profile (legacy save path).

func SaveProfiles

func SaveProfiles(pf *ProfilesFile) error

SaveProfiles writes profiles.json (mode 0600).

func SetProfile

func SetProfile(name string, cfg *Config) error

SetProfile saves credentials under name and sets it active.

func UseProfile

func UseProfile(name string) error

UseProfile switches the active profile.

Types

type Config

type Config struct {
	Host  string `json:"host"`
	Token string `json:"token"`
}

Config stores GitLab authentication information.

func Load

func Load() (*Config, error)

Load reads the configuration with three-tier precedence:

GITLAB_CLI_HOST  / GITLAB_CLI_TOKEN   (highest, isolates this CLI from glab)
GITLAB_HOST      / GITLAB_TOKEN       (compatible with glab and other GitLab tooling)
~/.gitlab-cli/config.json             (saved by `gitlab-cli auth login`)

Returns an empty Config (no error) if no source has values. Corrupt config JSON returns an explicit error.

func MustLoad

func MustLoad() (*Config, error)

MustLoad reads the configuration and validates required fields.

type ProfilesFile

type ProfilesFile struct {
	Active   string             `json:"active"`
	Profiles map[string]*Config `json:"profiles"`
}

ProfilesFile stores named GitLab credentials and the active profile name.

func LoadProfiles

func LoadProfiles() (*ProfilesFile, error)

LoadProfiles reads ~/.gitlab-cli/profiles.json.

Jump to

Keyboard shortcuts

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