Documentation
¶
Index ¶
- func ClearStoredCredentials() error
- func CredentialStorageBackend() string
- func CredentialStorageEncrypted() bool
- func Delete() error
- func DeleteProfile(name string) error
- func Dir() string
- func FilePath() string
- func IsConfigured() bool
- func ProfileNames(pf *ProfilesFile) []string
- func Save(cfg *Config) error
- func SaveProfiles(pf *ProfilesFile) error
- func SetProfile(name string, cfg *Config) error
- func UseProfile(name string) error
- type Config
- type ProfilesFile
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 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 SaveProfiles ¶
func SaveProfiles(pf *ProfilesFile) error
SaveProfiles writes profiles.json (mode 0600).
func SetProfile ¶
SetProfile saves credentials under name and sets it active.
Types ¶
type Config ¶
Config stores GitLab authentication information.
func Load ¶
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
LoadStoredConfig reads ~/.gitlab-cli/config.json directly. Current files are encrypted; plaintext legacy files are still accepted and rewritten encrypted on the next save.
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.