Documentation
¶
Overview ¶
Package config manages the Glean CLI's configuration, providing secure storage of credentials using the system keyring with fallback to file-based storage.
Index ¶
- Variables
- func ClearConfig() error
- func ClearTokenFromStorage() error
- func MaskToken(token string) string
- func NormalizeHost(host string) string
- func SaveConfig(host, token string) error
- func SaveHostToFile(host string) error
- func ValidateAndTransformHost(host string) (string, error)
- type Config
- type ProjectConfig
Constants ¶
This section is empty.
Variables ¶
var ConfigPath string
ConfigPath is the path to the fallback config file.
var ServiceName = "glean-cli"
ServiceName is the service identifier used for keyring operations.
Functions ¶
func ClearConfig ¶
func ClearConfig() error
ClearConfig removes all stored configuration from both keyring and file storage.
func ClearTokenFromStorage ¶ added in v0.13.0
func ClearTokenFromStorage() error
ClearTokenFromStorage removes only the API token from keyring and config file, leaving the host and other settings intact. This is used during OAuth login to prevent a stale API token from shadowing newly obtained OAuth credentials.
func MaskToken ¶
MaskToken masks a token by showing only the first and last 4 characters and replacing the rest with asterisks.
func NormalizeHost ¶
NormalizeHost ensures the Glean host is in the correct format, transforming short names (e.g., "linkedin") to full hostnames (e.g., "linkedin-be.glean.com"). Full hostnames (containing a ".") are returned unchanged.
func SaveConfig ¶
SaveConfig stores host and token in both the system keyring and file storage.
func SaveHostToFile ¶ added in v0.9.2
SaveHostToFile persists only the host in ~/.glean/config.json without touching the system keyring. This is intended for OAuth flows where the host is not secret and persisting it should not trigger OS keychain prompts.
func ValidateAndTransformHost ¶
ValidateAndTransformHost is a compatibility wrapper around NormalizeHost.
Types ¶
type Config ¶
type Config struct {
GleanHost string `json:"host"`
GleanToken string `json:"token"`
OAuthClientID string `json:"oauth_client_id,omitempty"`
OAuthClientSecret string `json:"oauth_client_secret,omitempty"`
}
Config holds the Glean API credentials and connection settings.
func LoadConfig ¶
LoadConfig retrieves configuration using the following priority order:
- Environment variables (GLEAN_API_TOKEN, GLEAN_HOST)
- System keyring
- ~/.glean/config.json
type ProjectConfig ¶ added in v0.14.0
type ProjectConfig struct {
DefaultOutput string `json:"default_output,omitempty"`
DefaultMode string `json:"default_mode,omitempty"`
DefaultFields string `json:"default_fields,omitempty"`
}
ProjectConfig holds project-level CLI preferences that can be shared via a .glean/config.json file checked into a repository.
func FindProjectConfig ¶ added in v0.14.0
func FindProjectConfig() (*ProjectConfig, error)
FindProjectConfig walks up from the current working directory looking for a .glean/config.json file. Returns nil, nil if no project config is found.