Documentation
¶
Overview ¶
Package config reads and writes the CLI's credentials file.
The file holds a server address and a token, and nothing else. Analysis scopes are not stored: they come from the process environment (see the env package), because several agents can share a machine while serving different projects.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Path ¶
Path returns the credentials file the current invocation reads and writes. METAXISDATA_CONFIG points at a specific file, which is how one machine keeps several identities apart; otherwise the XDG configuration directory is used.
func Save ¶
func Save(path string, credentials *Credentials) error
Save writes the file with owner-only permissions, creating its directory if needed. It writes a temporary file and renames it, so a crash cannot leave a half-written credentials file behind.
Types ¶
type Credentials ¶
type Credentials struct {
Server string `json:"server"`
Token string `json:"token"`
User *User `json:"user,omitempty"`
TokenExpiresAt time.Time `json:"tokenExpiresAt,omitzero"`
}
Credentials is the on-disk shape. The token is written in clear text: the CLI treats a credential file as equivalent to a seven day session, and hiding it from a local file was not worth a keychain dependency.
func Load ¶
func Load(path string) (*Credentials, error)
Load reads the credentials file. A missing file is not an error: it simply means nothing has been configured yet, and the caller decides what to do.
func (*Credentials) Clear ¶
func (c *Credentials) Clear()
Clear removes the token but keeps the server address: signing out is not the same as pointing at another server, and the address does not change.