go.bigb.es/curator

v1.3.1
Doc Versions Source

Index

Functions

f func ImportFromConfigFile

src
func ImportFromConfigFile(st *Store, path string) (modules int, patterns int, err error)

ImportFromConfigFile reads an old config.json and imports modules and patterns into the store.

f func VerifyModule

src
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.

f func VerifyPattern

src
func VerifyPattern(pattern string) error

VerifyPattern checks that a regex pattern compiles.

Types

T type CredentialResolver

src
type CredentialResolver interface {
	GetCredential(name string) (CredentialRow, error)
}

CredentialResolver abstracts credential lookup.

T type CredentialRow

src
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.

T type ModuleLister

src
type ModuleLister interface {
	ListModules() ([]ModuleRow, error)
	ListPatterns() ([]PatternRow, error)
}

ModuleLister abstracts listing modules and patterns for the landing page.

T type ModuleResolver

src
type ModuleResolver interface {
	ResolveModule(name string) (config.Module, bool)
}

ModuleResolver abstracts module lookup for the server.

T type ModuleRow

src
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.

T type PatternRow

src
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.

T type Store

src
type Store struct {
	// contains filtered or unexported fields
}

Store is a database-backed module store implementing ModuleResolver. It supports both SQLite and PostgreSQL backends.

f func Open

src
func Open(driver, dsn string) (*Store, error)

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").

m func (*Store) AddCredential

src
func (st *Store) AddCredential(c CredentialRow) error

AddCredential inserts a new credential.

m func (*Store) AddModule

src
func (st *Store) AddModule(m ModuleRow) error

AddModule adds a module to the database.

m func (*Store) AddPattern

src
func (st *Store) AddPattern(p PatternRow) error

AddPattern adds a module pattern to the database and refreshes the cache.

m func (*Store) Close

src
func (st *Store) Close() error

Close closes the database connection.

m func (*Store) CredentialCount

src
func (st *Store) CredentialCount() int

CredentialCount returns the total number of credentials.

m func (*Store) DeleteCredential

src
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.

m func (*Store) DeleteModule

src
func (st *Store) DeleteModule(name string) error

DeleteModule removes a module from the database.

m func (*Store) DeletePattern

src
func (st *Store) DeletePattern(id int64) error

DeletePattern removes a module pattern and refreshes the cache.

m func (*Store) GetCredential

src
func (st *Store) GetCredential(name string) (CredentialRow, error)

GetCredential returns a credential by name.

m func (*Store) GetHashes

src
func (st *Store) GetHashes(ctx context.Context, ids []int64) ([][]byte, error)

GetHashes returns hashes for the given IDs, in the order requested.

m func (*Store) GetRecords

src
func (st *Store) GetRecords(ctx context.Context, startID, count int64) ([][]byte, error)

GetRecords returns record data for IDs [startID, startID+count).

m func (*Store) ListCredentials

src
func (st *Store) ListCredentials() ([]CredentialRow, error)

ListCredentials returns all credentials ordered by name.

m func (*Store) ListModules

src
func (st *Store) ListModules() ([]ModuleRow, error)

ListModules returns all modules.

m func (*Store) ListPatterns

src
func (st *Store) ListPatterns() ([]PatternRow, error)

ListPatterns returns all module patterns ordered by priority.

m func (*Store) LookupRecord

src
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.

m func (*Store) ModuleCount

src
func (st *Store) ModuleCount() int

ModuleCount returns the total number of configured modules (exact + patterns).

m func (*Store) RecordCount

src
func (st *Store) RecordCount(ctx context.Context) (int64, error)

RecordCount returns the total number of sumdb records.

m func (*Store) ResolveModule

src
func (st *Store) ResolveModule(name string) (config.Module, bool)

ResolveModule looks up a module by name: exact match first, then patterns.

m func (*Store) SaveRecord

src
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.

m func (*Store) UpdateCredential

src
func (st *Store) UpdateCredential(c CredentialRow) error

UpdateCredential updates an existing credential's type and data.

m func (*Store) UpdateModule

src
func (st *Store) UpdateModule(m ModuleRow) error

UpdateModule updates a module's fields (except name, which is the PK).

m func (*Store) UpdatePattern

src
func (st *Store) UpdatePattern(p PatternRow) error

UpdatePattern updates a module pattern and refreshes the cache.

T type SumdbStore

src
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.