Documentation
¶
Overview ¶
Package tokens manages the local ~/.instant-tokens file that persists provisioned resource tokens between CLI invocations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry struct {
Token string `json:"token"`
Name string `json:"name"`
Type string `json:"type,omitempty"` // resource_type: postgres|redis|mongodb|queue|storage|webhook|vector
Env string `json:"env,omitempty"` // environment: development|production|staging|...
URL string `json:"url"` // connection URL or other primary URL
Schedule string `json:"schedule,omitempty"` // B15-P2-12 — omitempty so phantom `"schedule":""` rows don't bleed into `status --json`
Source string `json:"source"` // e.g. "provision"
CreatedAt time.Time `json:"created_at"`
}
Entry represents one saved resource token and metadata.
B15-P1 (7) — Type and Env fields enable anonymous-tier `instant up` idempotency. The anonymous caller can't list resources from the API (no auth), so `up` falls back to this local cache to recognize a previously-provisioned (type, name, env) tuple and skip re-provisioning. Older config files that lack these fields deserialize as empty strings; the up code-path skips them via empty-string checks rather than re-provisioning blind. Tokens written by `instant <type> new` since this release populate Type; Env will only be populated when written by `up`.
type Store ¶
type Store struct {
Entries []Entry `json:"entries"`
// contains filtered or unexported fields
}
Store is the in-memory representation of ~/.instant-tokens.
func (*Store) FindByTypeNameEnv ¶
FindByTypeNameEnv returns the entry matching (type, name, env) for the local idempotency cache used by anonymous `up`. Match is case-insensitive on type+name. An entry with an empty Type field is never returned (legacy rows from before B15-P1 — we can't safely claim them belong to a given type without a round trip). Returns nil if no entry matches.
func (*Store) Remove ¶
Remove drops the entry matching token and saves. Returns true when an entry was actually removed; false when the token was unknown. Callers MUST NOT depend on Remove for security — the source of truth is the API. Used by `instant resource delete` to keep `instant status` honest.