Documentation
¶
Overview ¶
Package vault is an always-on project archive store for multi-device / multi- operator sync. It holds full-project zips (same layout as control's export) under a configurable directory — typically served over Tailscale Serve.
Index ¶
- func NormalizeAddr(addr string) string
- func ParseRev(s string) (int, error)
- func ValidSlug(id string) bool
- type Auth
- type ProjectInfo
- type RevInfo
- type Server
- type Store
- func (s *Store) DeleteProject(id string) error
- func (s *Store) DeleteRev(id string, rev int) error
- func (s *Store) List() ([]ProjectInfo, error)
- func (s *Store) OpenRev(id string, rev int) (io.ReadCloser, RevInfo, error)
- func (s *Store) Put(id, label, source string, r io.Reader) (RevInfo, error)
- func (s *Store) Revisions(id string) ([]RevInfo, error)
- func (s *Store) Status() map[string]any
- type TokenScope
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeAddr ¶
NormalizeAddr ensures host:port (default 127.0.0.1:9977).
Types ¶
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth manages vault bearer tokens (hashed at rest).
func (*Auth) Check ¶
func (a *Auth) Check(authHeader string) (TokenScope, error)
Check validates Authorization bearer and returns scope.
func (*Auth) Create ¶
func (a *Auth) Create(scope TokenScope, label string) (raw string, rec tokenRecord, err error)
Create mints a new token.
func (*Auth) EnsureBootstrap ¶
EnsureBootstrap creates a full-scope token if none exist. Returns the raw token (only shown once) and whether it was newly created.
type ProjectInfo ¶
type ProjectInfo struct {
ID string `json:"id"`
Revisions int `json:"revisions"`
LatestRev int `json:"latestRev"`
LatestSize int64 `json:"latestSize"`
LatestAt int64 `json:"latestAt"`
LatestLabel string `json:"latestLabel,omitempty"`
LatestSHA256 string `json:"latestSha256,omitempty"`
}
ProjectInfo is a list-row for one vault project.
type RevInfo ¶
type RevInfo struct {
Rev int `json:"rev"`
Size int64 `json:"size"`
SHA256 string `json:"sha256"`
At int64 `json:"at"`
Label string `json:"label,omitempty"`
Source string `json:"source,omitempty"`
Filename string `json:"filename"`
}
RevInfo describes one stored revision.
type Server ¶
type Server struct {
Store *Store
Auth *Auth
Addr string // listen address (set after Listen)
// contains filtered or unexported fields
}
Server is the HTTP vault API.
func (*Server) ListenAndServe ¶
ListenAndServe binds addr and serves until ln is closed.
type Store ¶
type Store struct {
Dir string
Keep int // max revisions per project; <=0 means 10
// contains filtered or unexported fields
}
Store is a filesystem-backed vault root.
func (*Store) DeleteProject ¶
DeleteProject removes a project and all revisions.
func (*Store) List ¶
func (s *Store) List() ([]ProjectInfo, error)
List returns every project with latest revision summary.
type TokenScope ¶
type TokenScope string
TokenScope is "full" (read+write) or "read".
const ( ScopeFull TokenScope = "full" ScopeRead TokenScope = "read" )