Documentation
¶
Overview ¶
Package vars implements the tailkitd var store: a per-scope, concurrency-safe key-value store persisted as JSON files under /etc/tailkitd/vars/.
Scope identity is "project/env". Each scope has its own *sync.RWMutex so concurrent reads across different scopes never block each other, and writes within a scope are serialised without blocking other scopes.
Invariants:
- Keys starting with "_" are reserved for internal metadata and are never returned to callers. Set rejects them with an error.
- _meta.updated_at and _meta.updated_by are written on every Set/Delete.
- All writes are atomic: temp file in same directory → rename.
Index ¶
- Constants
- type Handler
- type Store
- func (s *Store) Delete(ctx context.Context, project, env, key, caller string) error
- func (s *Store) DeleteScope(ctx context.Context, project, env string) error
- func (s *Store) Get(ctx context.Context, project, env, key string) (string, error)
- func (s *Store) List(ctx context.Context, project, env string) (map[string]string, error)
- func (s *Store) RenderEnv(ctx context.Context, project, env string) (string, error)
- func (s *Store) Set(ctx context.Context, project, env, key, value, caller string) error
Constants ¶
const ( ErrScopeNotFound = storeError("vars: scope not found") ErrKeyNotFound = storeError("vars: key not found") ErrReservedKey = storeError("vars: key is reserved (_-prefixed keys are internal)") ErrInvalidKey = storeError("vars: invalid key format") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler serves all /vars/* endpoints.
GET /vars — list all configured scopes
GET /vars/{project}/{env} — list all keys in scope (JSON map)
GET /vars/{project}/{env}?format=env — render as KEY=VALUE text
GET /vars/{project}/{env}/{key} — get a single key
PUT /vars/{project}/{env}/{key} — set a key (body: plain text value)
DELETE /vars/{project}/{env}/{key} — delete a key
DELETE /vars/{project}/{env} — delete entire scope
func NewHandler ¶
NewHandler constructs a vars Handler.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the var store. It holds per-scope mutexes in a sync.Map and persists data as JSON files on disk.
func NewStore ¶
NewStore constructs a Store rooted at baseDir. Call with defaultBaseDir ("/etc/tailkitd/vars") in production.
func (*Store) Delete ¶
Delete removes a key from a scope and updates _meta.*. Returns ErrReservedKey if key starts with "_". Returns nil (not an error) if the key did not exist.
func (*Store) DeleteScope ¶
DeleteScope removes the entire scope file. Returns nil if the scope did not exist.
func (*Store) Get ¶
Get returns the value of a single key in a scope. Returns ("", ErrKeyNotFound) if the key does not exist. Returns ErrReservedKey if the key starts with "_".
func (*Store) List ¶
List returns all non-reserved keys and their values for a scope. Keys starting with "_" are stripped before returning. Returns ErrScopeNotFound if the scope file does not exist.