Documentation
¶
Index ¶
- func ClearStoredCredentials() error
- 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 and profiles.json (logout).
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.
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.