store

package
v0.0.0-...-a7ced60 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRecordNotFound error = errors.New("record not found")
)

Functions

func Commit

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

func FromContext

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

func GenerateDefaultInventory

func GenerateDefaultInventory() api.Inventory

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)
	InitialMigration(context.Context) 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) InitialMigration

func (a *AgentStore) InitialMigration(ctx context.Context) error

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 BaseQuerier

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

type DataStore

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

func (*DataStore) Agent

func (s *DataStore) Agent() Agent

func (*DataStore) Close

func (s *DataStore) Close() error

func (*DataStore) ImageInfra

func (s *DataStore) ImageInfra() ImageInfra

func (*DataStore) InitialMigration

func (s *DataStore) InitialMigration() error

func (*DataStore) NewTransactionContext

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

func (*DataStore) Seed

func (s *DataStore) Seed() error

func (*DataStore) Source

func (s *DataStore) Source() Source

type ImageInfra

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

func NewImageInfraStore

func NewImageInfraStore(db *gorm.DB) ImageInfra

type ImageInfraStore

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

func (*ImageInfraStore) Create

func (*ImageInfraStore) InitialMigration

func (i *ImageInfraStore) InitialMigration(ctx context.Context) 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)
	InitialMigration(context.Context) error
}

func NewSource

func NewSource(db *gorm.DB) Source

type SourceQueryFilter

type SourceQueryFilter BaseQuerier

func NewSourceQueryFilter

func NewSourceQueryFilter() *SourceQueryFilter

func (*SourceQueryFilter) ByDefaultInventory

func (sf *SourceQueryFilter) ByDefaultInventory() *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) InitialMigration

func (s *SourceStore) InitialMigration(ctx context.Context) 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
	Seed() error
	InitialMigration() 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