Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Backend ¶
type Backend interface {
Load(baseURL string) (Credential, error)
Save(credential Credential) error
Delete(baseURL string) error
Hosts() ([]string, error)
}
Backend is the credential storage contract. The file store is the only implementation today; a keychain backend would satisfy the same interface. Load and Delete are keyed by the normalized Control Plane base URL so a login to a second host never overwrites the first.
type Credential ¶
type Credential struct {
BaseURL string `json:"-"`
Token string `json:"token"`
AccountEmail string `json:"account_email,omitempty"`
ExpiresAt string `json:"expires_at,omitempty"`
}
Credential is one Control Plane token bound to the normalized base URL it was issued for. Tokens for different hosts never share an entry.
type Store ¶
type Store struct {
Path string
}
Store is the owner-only JSON file backend.
func (Store) Delete ¶
Delete removes one host's credential. The file is removed once it holds no credentials at all. A missing entry is not an error.
func (Store) Load ¶
func (s Store) Load(baseURL string) (Credential, error)
Load returns the credential stored for baseURL, or fs.ErrNotExist when the file or that host's entry is absent.
func (Store) Save ¶
func (s Store) Save(credential Credential) error
Save stores the credential under its base URL, keeping every other host's entry. A version 1 file is rewritten as version 2 on the way through.