store

package
v0.5.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound = errors.New("record not found")
	ErrDuplicateKey   = errors.New("already exists")
)

Functions

func Commit

func Commit(ctx context.Context) (context.Context, error)

func FromContext

func FromContext(ctx context.Context) *gorm.DB

func InitDB

func InitDB(cfg *config.Config) (*gorm.DB, error)

func Rollback

func Rollback(ctx context.Context) (context.Context, error)

Types

type Agent

type Agent interface {
	List(ctx context.Context, filter *AgentQueryFilter, opts *AgentQueryOptions) (model.AgentList, error)
	Get(ctx context.Context, id uuid.UUID) (*model.Agent, error)
	Update(ctx context.Context, agent model.Agent) (*model.Agent, error)
	Create(ctx context.Context, agent model.Agent) (*model.Agent, error)
}

func NewAgentSource

func NewAgentSource(db *gorm.DB) Agent

type AgentQueryFilter

type AgentQueryFilter BaseQuerier

func NewAgentQueryFilter

func NewAgentQueryFilter() *AgentQueryFilter

func (*AgentQueryFilter) ByID

func (qf *AgentQueryFilter) ByID(ids []string) *AgentQueryFilter

func (*AgentQueryFilter) BySourceID

func (qf *AgentQueryFilter) BySourceID(sourceID string) *AgentQueryFilter

type AgentQueryOptions

type AgentQueryOptions BaseQuerier

func NewAgentQueryOptions

func NewAgentQueryOptions() *AgentQueryOptions

func (*AgentQueryOptions) WithSortOrder

func (o *AgentQueryOptions) WithSortOrder(sort SortOrder) *AgentQueryOptions

type AgentStore

type AgentStore struct {
	// contains filtered or unexported fields
}

func (*AgentStore) Create

func (a *AgentStore) Create(ctx context.Context, agent model.Agent) (*model.Agent, error)

Create creates an agent.

func (*AgentStore) Get

func (a *AgentStore) Get(ctx context.Context, id uuid.UUID) (*model.Agent, error)

Get returns an agent based on its id.

func (*AgentStore) List

List lists all the agents.

func (*AgentStore) Update

func (a *AgentStore) Update(ctx context.Context, agent model.Agent) (*model.Agent, error)

Update updates an agent.

type Assessment

type Assessment interface {
	List(ctx context.Context, filter *AssessmentQueryFilter) (model.AssessmentList, error)
	Get(ctx context.Context, id uuid.UUID) (*model.Assessment, error)
	Create(ctx context.Context, assessment model.Assessment, inventory []byte) (*model.Assessment, error)
	Update(ctx context.Context, assessmentID uuid.UUID, name *string, inventory []byte) (*model.Assessment, error)
	Delete(ctx context.Context, id uuid.UUID) error
}

func NewAssessmentStore

func NewAssessmentStore(db *gorm.DB) Assessment

type AssessmentQueryFilter

type AssessmentQueryFilter struct {
	QueryFn []func(*gorm.DB) *gorm.DB
}

func NewAssessmentQueryFilter

func NewAssessmentQueryFilter() *AssessmentQueryFilter

func (*AssessmentQueryFilter) WithNameLike

func (f *AssessmentQueryFilter) WithNameLike(pattern string) *AssessmentQueryFilter

Filter by name pattern

func (*AssessmentQueryFilter) WithOrgID

func (f *AssessmentQueryFilter) WithOrgID(orgID string) *AssessmentQueryFilter

Filter by organization ID

func (*AssessmentQueryFilter) WithSourceID

func (f *AssessmentQueryFilter) WithSourceID(sourceID string) *AssessmentQueryFilter

Filter by source ID

func (*AssessmentQueryFilter) WithSourceType

func (f *AssessmentQueryFilter) WithSourceType(sourceType string) *AssessmentQueryFilter

Filter by source

func (*AssessmentQueryFilter) WithUsername added in v0.3.0

func (f *AssessmentQueryFilter) WithUsername(username string) *AssessmentQueryFilter

Filter by username

type AssessmentQueryOptions

type AssessmentQueryOptions struct {
	QueryFn []func(*gorm.DB) *gorm.DB
}

func NewAssessmentQueryOptions

func NewAssessmentQueryOptions() *AssessmentQueryOptions

func (*AssessmentQueryOptions) WithLimit

func (o *AssessmentQueryOptions) WithLimit(limit int) *AssessmentQueryOptions

Limit results

func (*AssessmentQueryOptions) WithOffset

func (o *AssessmentQueryOptions) WithOffset(offset int) *AssessmentQueryOptions

Offset results

func (*AssessmentQueryOptions) WithOrder

Order by specific field

type AssessmentStore

type AssessmentStore struct {
	// contains filtered or unexported fields
}

func (*AssessmentStore) Create

func (a *AssessmentStore) Create(ctx context.Context, assessment model.Assessment, inventory []byte) (*model.Assessment, error)

func (*AssessmentStore) Delete

func (a *AssessmentStore) Delete(ctx context.Context, id uuid.UUID) error

func (*AssessmentStore) Get

func (*AssessmentStore) List

func (*AssessmentStore) Update

func (a *AssessmentStore) Update(ctx context.Context, assessmentID uuid.UUID, name *string, inventory []byte) (*model.Assessment, error)

type BaseQuerier

type BaseQuerier struct {
	QueryFn []func(tx *gorm.DB) *gorm.DB
}

type CacheKeyStore

type CacheKeyStore struct {
	// contains filtered or unexported fields
}

CacheKeyStore is wrapper around PrivateKeyStore which provide basic caching of the public keys.

func (*CacheKeyStore) Create

func (p *CacheKeyStore) Create(ctx context.Context, privateKey model.Key) (*model.Key, error)

func (*CacheKeyStore) Delete

func (p *CacheKeyStore) Delete(ctx context.Context, orgID string) error

func (*CacheKeyStore) Get

func (p *CacheKeyStore) Get(ctx context.Context, orgID string) (*model.Key, error)

func (*CacheKeyStore) GetPublicKey added in v0.2.2

func (p *CacheKeyStore) GetPublicKey(ctx context.Context, id string) (crypto.PublicKey, error)

type DataStore

type DataStore struct {
	// contains filtered or unexported fields
}

func (*DataStore) Agent

func (s *DataStore) Agent() Agent

func (*DataStore) Assessment

func (s *DataStore) Assessment() Assessment

func (*DataStore) Close

func (s *DataStore) Close() error

func (*DataStore) ImageInfra

func (s *DataStore) ImageInfra() ImageInfra

func (*DataStore) Job added in v0.3.0

func (s *DataStore) Job() Job

func (*DataStore) Label

func (s *DataStore) Label() Label

func (*DataStore) NewTransactionContext

func (s *DataStore) NewTransactionContext(ctx context.Context) (context.Context, error)

func (*DataStore) PrivateKey

func (s *DataStore) PrivateKey() PrivateKey

func (*DataStore) Source

func (s *DataStore) Source() Source

func (*DataStore) Statistics

func (s *DataStore) Statistics(ctx context.Context) (model.InventoryStats, error)

type ImageInfra

type ImageInfra interface {
	Create(ctx context.Context, imageInfra model.ImageInfra) (*model.ImageInfra, error)
	Update(ctx context.Context, imageInfra model.ImageInfra) (*model.ImageInfra, error)
}

func NewImageInfraStore

func NewImageInfraStore(db *gorm.DB) ImageInfra

type ImageInfraStore

type ImageInfraStore struct {
	// contains filtered or unexported fields
}

func (*ImageInfraStore) Create

func (*ImageInfraStore) Update

type Job added in v0.3.0

type Job interface {
	Get(ctx context.Context, id int64) (*JobRow, error)
	UpdateMetadata(ctx context.Context, id int64, metadataJSON []byte) error
}

Job interface for job-related database operations

func NewJobStore added in v0.3.0

func NewJobStore(db *gorm.DB) Job

NewJobStore creates a new job store

type JobRow added in v0.3.0

type JobRow struct {
	ID           int64              `gorm:"column:id;primaryKey"`
	State        rivertype.JobState `gorm:"column:state"`
	ArgsJSON     []byte             `gorm:"column:args"`
	MetadataJSON []byte             `gorm:"column:metadata"`
}

JobRow represents a row from the river_job table

func (JobRow) TableName added in v0.3.0

func (JobRow) TableName() string

TableName specifies the table name for GORM

type JobStore added in v0.3.0

type JobStore struct {
	// contains filtered or unexported fields
}

JobStore implements the Job interface

func (*JobStore) Get added in v0.3.0

func (s *JobStore) Get(ctx context.Context, id int64) (*JobRow, error)

Get retrieves a job by ID from the river_job table

func (*JobStore) UpdateMetadata added in v0.3.0

func (s *JobStore) UpdateMetadata(ctx context.Context, id int64, metadataJSON []byte) error

UpdateMetadata updates the metadata of a job

type Label

type Label interface {
	DeleteBySourceID(ctx context.Context, sourceID string) error
	UpdateLabels(ctx context.Context, sourceID uuid.UUID, labels []model.Label) error
}

func NewLabelStore

func NewLabelStore(db *gorm.DB) Label

type PrivateKey

type PrivateKey interface {
	Create(ctx context.Context, privateKey model.Key) (*model.Key, error)
	Get(ctx context.Context, orgID string) (*model.Key, error)
	Delete(ctx context.Context, orgID string) error
	GetPublicKey(ctx context.Context, id string) (crypto.PublicKey, error)
}

func NewCacheKeyStore

func NewCacheKeyStore(delegate PrivateKey) PrivateKey

func NewPrivateKey

func NewPrivateKey(db *gorm.DB) PrivateKey

type PrivateKeyStore

type PrivateKeyStore struct {
	// contains filtered or unexported fields
}

func (*PrivateKeyStore) Create

func (p *PrivateKeyStore) Create(ctx context.Context, privateKey model.Key) (*model.Key, error)

func (*PrivateKeyStore) Delete

func (p *PrivateKeyStore) Delete(ctx context.Context, orgID string) error

func (*PrivateKeyStore) Get

func (p *PrivateKeyStore) Get(ctx context.Context, orgID string) (*model.Key, error)

func (*PrivateKeyStore) GetPublicKey added in v0.2.2

func (p *PrivateKeyStore) GetPublicKey(ctx context.Context, kid string) (crypto.PublicKey, error)

type SortOrder

type SortOrder int
const (
	Unsorted SortOrder = iota
	SortByID
	SortByUpdatedTime
	SortByCreatedTime
)

type Source

type Source interface {
	List(ctx context.Context, filter *SourceQueryFilter) (model.SourceList, error)
	Create(ctx context.Context, source model.Source) (*model.Source, error)
	DeleteAll(ctx context.Context) error
	Get(ctx context.Context, id uuid.UUID) (*model.Source, error)
	Delete(ctx context.Context, id uuid.UUID) error
	Update(ctx context.Context, source model.Source) (*model.Source, error)
}

func NewSource

func NewSource(db *gorm.DB) Source

type SourceQueryFilter

type SourceQueryFilter BaseQuerier

func NewSourceQueryFilter

func NewSourceQueryFilter() *SourceQueryFilter

func (*SourceQueryFilter) ByOnPremises

func (qf *SourceQueryFilter) ByOnPremises(isOnPremises bool) *SourceQueryFilter

func (*SourceQueryFilter) ByOrgID

func (sf *SourceQueryFilter) ByOrgID(id string) *SourceQueryFilter

func (*SourceQueryFilter) ByUsername

func (sf *SourceQueryFilter) ByUsername(username string) *SourceQueryFilter

type SourceStore

type SourceStore struct {
	// contains filtered or unexported fields
}

func (*SourceStore) Create

func (s *SourceStore) Create(ctx context.Context, source model.Source) (*model.Source, error)

func (*SourceStore) Delete

func (s *SourceStore) Delete(ctx context.Context, id uuid.UUID) error

func (*SourceStore) DeleteAll

func (s *SourceStore) DeleteAll(ctx context.Context) error

func (*SourceStore) Get

func (s *SourceStore) Get(ctx context.Context, id uuid.UUID) (*model.Source, error)

func (*SourceStore) List

func (*SourceStore) Update

func (s *SourceStore) Update(ctx context.Context, source model.Source) (*model.Source, error)

type Store

type Store interface {
	NewTransactionContext(ctx context.Context) (context.Context, error)
	Agent() Agent
	Source() Source
	ImageInfra() ImageInfra
	PrivateKey() PrivateKey
	Label() Label
	Assessment() Assessment
	Job() Job
	Statistics(ctx context.Context) (model.InventoryStats, error)
	Close() error
}

func NewStore

func NewStore(db *gorm.DB) Store

type Tx

type Tx struct {
	// contains filtered or unexported fields
}

func (*Tx) Commit

func (t *Tx) Commit() error

func (*Tx) Db

func (t *Tx) Db() (*gorm.DB, error)

func (*Tx) Rollback

func (t *Tx) Rollback() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL