go.bigb.es/curator
Index
- func ImportFromConfigFile(st *Store, path string) (modules int, patterns int, err error)
- func VerifyModule(repo string, auth transport.AuthMethod) error
- func VerifyPattern(pattern string) error
- type CredentialResolver
- type CredentialRow
- type ModuleLister
- type ModuleResolver
- type ModuleRow
- type PatternRow
- type Store
- func Open(driver, dsn string) (*Store, error)
- func (*Store) AddCredential(c CredentialRow) error
- func (*Store) AddModule(m ModuleRow) error
- func (*Store) AddPattern(p PatternRow) error
- func (*Store) Close() error
- func (*Store) CredentialCount() int
- func (*Store) DeleteCredential(name string) error
- func (*Store) DeleteModule(name string) error
- func (*Store) DeletePattern(id int64) error
- func (*Store) GetCredential(name string) (CredentialRow, error)
- func (*Store) GetHashes(ctx context.Context, ids []int64) ([][]byte, error)
- func (*Store) GetRecords(ctx context.Context, startID, count int64) ([][]byte, error)
- func (*Store) ListCredentials() ([]CredentialRow, error)
- func (*Store) ListModules() ([]ModuleRow, error)
- func (*Store) ListPatterns() ([]PatternRow, error)
- func (*Store) LookupRecord(ctx context.Context, key string) (int64, bool, error)
- func (*Store) ModuleCount() int
- func (*Store) RecordCount(ctx context.Context) (int64, error)
- func (*Store) ResolveModule(name string) (config.Module, bool)
- func (*Store) SaveRecord(ctx context.Context, recordID int64, key string, data []byte, hashStartID int64, hashes [][]byte) error
- func (*Store) UpdateCredential(c CredentialRow) error
- func (*Store) UpdateModule(m ModuleRow) error
- func (*Store) UpdatePattern(p PatternRow) error
- type SumdbStore
Functions
func ImportFromConfigFile(st *Store, path string) (modules int, patterns int, err error)
func VerifyModule(repo string, auth transport.AuthMethod) error
VerifyModule checks that a git repository is accessible. If auth is non-nil, it is used for authentication.
func VerifyPattern(pattern string) error
VerifyPattern checks that a regex pattern compiles.
Types
type CredentialResolver interface { GetCredential(name string) (CredentialRow, error) }
CredentialResolver abstracts credential lookup.
type CredentialRow struct { Name string `json:"name"` Type string `json:"type"` Data string `json:"data,omitempty"` CreatedAt string `json:"created_at,omitempty"` }
CredentialRow represents a named credential stored in the database.
type ModuleLister interface { ListModules() ([]ModuleRow, error) ListPatterns() ([]PatternRow, error) }
ModuleLister abstracts listing modules and patterns for the landing page.
type ModuleResolver interface { ResolveModule(name string) (config.Module, bool) }
ModuleResolver abstracts module lookup for the server.
type ModuleRow struct { Name string `json:"name"` VCS string `json:"vcs"` Repo string `json:"repo"` Web string `json:"web"` Private bool `json:"private"` CredentialName string `json:"credential_name,omitempty"` CreatedAt string `json:"created_at,omitempty"` }
ModuleRow represents a module stored in the database.
type PatternRow struct { ID int64 `json:"id"` Pattern string `json:"pattern"` VCS string `json:"vcs"` Repo string `json:"repo"` Web string `json:"web"` Private bool `json:"private"` Priority int `json:"priority"` CredentialName string `json:"credential_name,omitempty"` CreatedAt string `json:"created_at,omitempty"` }
PatternRow represents a module pattern stored in the database.
type Store struct { // contains filtered or unexported fields }
Store is a database-backed module store implementing ModuleResolver. It supports both SQLite and PostgreSQL backends.
Open opens a database with the given driver and DSN, then runs migrations. Supported drivers: "sqlite", "postgres".
For SQLite the DSN is a file path (WAL mode and busy timeout are set automatically). For PostgreSQL the DSN is a connection string (e.g. "postgres://user:pass@host/db?sslmode=disable").
func (st *Store) AddCredential(c CredentialRow) error
AddCredential inserts a new credential.
AddModule adds a module to the database.
func (st *Store) AddPattern(p PatternRow) error
AddPattern adds a module pattern to the database and refreshes the cache.
func (st *Store) CredentialCount() int
CredentialCount returns the total number of credentials.
func (st *Store) DeleteCredential(name string) error
DeleteCredential removes a credential by name. It returns an error if the credential is referenced by any module or pattern.
func (st *Store) DeleteModule(name string) error
DeleteModule removes a module from the database.
func (st *Store) DeletePattern(id int64) error
DeletePattern removes a module pattern and refreshes the cache.
func (st *Store) GetCredential(name string) (CredentialRow, error)
GetCredential returns a credential by name.
func (st *Store) GetHashes(ctx context.Context, ids []int64) ([][]byte, error)
GetHashes returns hashes for the given IDs, in the order requested.
func (st *Store) GetRecords(ctx context.Context, startID, count int64) ([][]byte, error)
GetRecords returns record data for IDs [startID, startID+count).
func (st *Store) ListCredentials() ([]CredentialRow, error)
ListCredentials returns all credentials ordered by name.
ListModules returns all modules.
func (st *Store) ListPatterns() ([]PatternRow, error)
ListPatterns returns all module patterns ordered by priority.
func (st *Store) LookupRecord(ctx context.Context, key string) (int64, bool, error)
LookupRecord returns the record ID for a key, or found=false if not present.
func (st *Store) ModuleCount() int
ModuleCount returns the total number of configured modules (exact + patterns).
func (st *Store) RecordCount(ctx context.Context) (int64, error)
RecordCount returns the total number of sumdb records.
func (st *Store) ResolveModule(name string) (config.Module, bool)
ResolveModule looks up a module by name: exact match first, then patterns.
func (st *Store) SaveRecord(ctx context.Context, recordID int64, key string, data []byte, hashStartID int64, hashes [][]byte) error
SaveRecord inserts a record and its hashes in a single transaction.
func (st *Store) UpdateCredential(c CredentialRow) error
UpdateCredential updates an existing credential's type and data.
UpdateModule updates a module's fields (except name, which is the PK).
func (st *Store) UpdatePattern(p PatternRow) error
UpdatePattern updates a module pattern and refreshes the cache.
type SumdbStore interface { // SaveRecord atomically persists a new record and its associated hashes. SaveRecord(ctx context.Context, recordID int64, key string, data []byte, hashStartID int64, hashes [][]byte) error // GetRecords returns record data for IDs [startID, startID+count). GetRecords(ctx context.Context, startID, count int64) ([][]byte, error) // GetHashes returns hashes for the given IDs, in the order requested. GetHashes(ctx context.Context, ids []int64) ([][]byte, error) // LookupRecord returns the record ID for a key, or found=false. LookupRecord(ctx context.Context, key string) (id int64, found bool, err error) // RecordCount returns the total number of sumdb records. RecordCount(ctx context.Context) (int64, error) }
SumdbStore is the persistence interface for sumdb transparency log state.
ImportFromConfigFile reads an old config.json and imports modules and patterns into the store.