Documentation
¶
Index ¶
Constants ¶
const ( AuthTypeAPIKey = "api_key" AuthTypeOAuth = "oauth" )
Auth type constants for Profile.AuthType.
Variables ¶
This section is empty.
Functions ¶
func DeleteProfile ¶
DeleteProfile removes a profile file from disk.
func MaskAPIKey ¶
MaskAPIKey returns a masked version of an API key for display.
func SaveProfile ¶
SaveProfile writes a profile to disk atomically, with 0600 permissions on POSIX systems (best-effort on Windows).
Atomic write semantics: the YAML is written to a sibling .tmp file, fsync'd, and renamed over the destination. A partial profile file is never observable to a concurrent reader.
func ValidateProfileName ¶
ValidateProfileName rejects profile names that contain path separators, parent references, or other unsafe characters.
Types ¶
type Config ¶
type Config struct {
ActiveProfile string `yaml:"active_profile"`
Defaults Defaults `yaml:"defaults"`
}
Config represents the global CLI configuration.
func (*Config) ActiveProfileData ¶
ActiveProfileData loads the currently active profile.
func (*Config) AllSettings ¶
AllSettings returns all config keys and their values.
func (*Config) SetActiveProfile ¶
SetActiveProfile updates the active profile name and saves.
type Defaults ¶
type Defaults struct {
Output string `yaml:"output"`
NoColor bool `yaml:"no_color"`
Workspace string `yaml:"workspace,omitempty"`
}
Defaults holds default CLI settings.
type Profile ¶
type Profile struct {
Name string `yaml:"name"`
APIKey string `yaml:"api_key,omitempty"`
PublicKey string `yaml:"public_key,omitempty"`
SecretKey string `yaml:"secret_key,omitempty"`
BaseURL string `yaml:"base_url"`
Environment string `yaml:"environment"`
Organization string `yaml:"organization,omitempty"`
// OAuth / SSO metadata. Empty for legacy API-key profiles.
AuthType string `yaml:"auth_type,omitempty"`
TokenRef string `yaml:"token_ref,omitempty"`
ExpiresAt time.Time `yaml:"expires_at,omitempty"`
UserID string `yaml:"user_id,omitempty"`
UserEmail string `yaml:"user_email,omitempty"`
}
Profile represents a named authentication profile.
Profiles support two authentication modes selected by AuthType:
- "api_key" (legacy): the credential pair (PublicKey + SecretKey) is stored explicitly. The combined APIKey field is retained for backward compatibility with profiles written by older CLI builds.
- "oauth" (SSO): no access/refresh tokens live in this file; tokens are stored in the OS keychain keyed by TokenRef. Only metadata (expiry, user id/email) is persisted here.
func ListProfiles ¶
ListProfiles returns all saved profiles.
func LoadProfile ¶
LoadProfile reads a profile by name from disk. If the profile is in the legacy single-string `api_key: pk:sk` shape and there are no `public_key`/`secret_key` fields, LoadProfile transparently splits the credential and rewrites the file atomically with the dual-key fields populated.
A migration write failure (disk full, perms, read-only FS) is non-fatal: a warning is logged and the in-memory Profile carries the split values for the duration of the session. The next start retries.