config

package
v1.2.16 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 16 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, profiles.json, and the keyring master key (logout).

func CredentialStorageBackend added in v1.2.1

func CredentialStorageBackend() string

CredentialStorageBackend reports the at-rest backend of stored credential files: "keyring", "encrypted-file", or "" when nothing is stored.

func CredentialStorageEncrypted added in v1.2.1

func CredentialStorageEncrypted() bool

CredentialStorageEncrypted reports whether existing on-disk credential files use the encrypted envelope format. Missing files are treated as compliant.

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 LoadStoredConfig added in v1.2.1

func LoadStoredConfig() (*Config, bool, error)

LoadStoredConfig reads ~/.gitlab-cli/config.json directly. Current files are encrypted; plaintext legacy files are still accepted and rewritten encrypted on the next save.

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