Documentation
¶
Overview ¶
Package config loads and persists the proteos CLI's stored credentials and resolves the effective base URL + token for a command, applying the precedence the CLI documents: explicit flag > environment variable > stored file.
Index ¶
Constants ¶
const ( EnvURL = "PROTEOS_URL" EnvToken = "PROTEOS_TOKEN" )
Environment overrides. These let an agent / CI run with no prior `auth login`.
Variables ¶
This section is empty.
Functions ¶
func Delete ¶
func Delete() error
Delete removes the stored credential file (a no-op if it is absent).
func Path ¶
Path returns the credential file path: $XDG_CONFIG_HOME/proteos/credentials.json, falling back to ~/.config/proteos/credentials.json.
func Save ¶
func Save(c Credentials) error
Save writes credentials to disk with 0600 perms, creating the parent dir 0700.
Types ¶
type Credentials ¶
type Credentials struct {
BaseURL string `json:"base_url"`
Token string `json:"token"`
Login string `json:"login,omitempty"`
}
Credentials is the on-disk credential file (mode 0600). Token is a personal access token minted from the browser Settings → CLI tokens page.
func Load ¶
func Load() (Credentials, error)
Load reads the stored credentials. A missing file is not an error — it returns a zero Credentials so first-run / env-only callers work.
Neither is an unlocatable home. For reading, "there is nowhere a credentials file could be" and "there is no credentials file there" are the same answer, and failing the first case breaks the env-only path this CLI documents: callers that export PROTEOS_URL and PROTEOS_TOKEN never wanted the file, and a container or systemd unit that sets neither XDG_CONFIG_HOME nor HOME would otherwise fail every command with "locate home dir" before the variables it was given are even consulted. Save and Delete still surface it, because they genuinely need a path.