sql

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: MPL-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package sql implements persistent storage using the sql database.

Index

Constants

View Source
const TestDatabaseURL = "OTF_TEST_DATABASE_URL"

Variables

This section is empty.

Functions

func FindUpdates

func FindUpdates(m *reflectx.Mapper, a, b interface{}) map[string]interface{}

FindUpdates compares two structs of identical type for any differences in their struct field values. A mapping is returned: the sqlx db path of the field mapped to the value found in the field in struct b. Relations are stripped out, i.e. those fields with a period in, e.g. 'parent.child'.

func New

func New(logger logr.Logger, path string, opts ...Option) (*sqlx.DB, error)

Types

type ApplyLogDB

type ApplyLogDB struct {
	*sqlx.DB
}

func NewApplyLogDB

func NewApplyLogDB(db *sqlx.DB) *ApplyLogDB

func (ApplyLogDB) GetChunk

func (db ApplyLogDB) GetChunk(ctx context.Context, applyID string, opts otf.GetChunkOptions) ([]byte, error)

GetChunk retrieves a log chunk from the DB.

func (ApplyLogDB) PutChunk

func (db ApplyLogDB) PutChunk(ctx context.Context, applyID string, chunk []byte, opts otf.PutChunkOptions) error

PutChunk persists a log chunk to the DB.

type ConfigurationVersionDB

type ConfigurationVersionDB struct {
	*sqlx.DB
}

func NewConfigurationVersionDB

func NewConfigurationVersionDB(db *sqlx.DB) *ConfigurationVersionDB

func (ConfigurationVersionDB) Create

func (ConfigurationVersionDB) Delete

func (db ConfigurationVersionDB) Delete(id string) error

Delete deletes a configuration version from the DB

func (ConfigurationVersionDB) Get

func (ConfigurationVersionDB) List

func (ConfigurationVersionDB) Update

Update persists an updated ConfigurationVersion to the DB. The existing run is fetched from the DB, the supplied func is invoked on the run, and the updated run is persisted back to the DB. The returned ConfigurationVersion includes any changes, including a new UpdatedAt value.

type Getter

type Getter interface {
	Get(dest interface{}, query string, args ...interface{}) error
	Select(dest interface{}, query string, args ...interface{}) error
}

type GooseLogger

type GooseLogger struct {
	*zerolog.Logger
}

func NewGooseLogger

func NewGooseLogger(zlogger *zerolog.Logger) *GooseLogger

func (*GooseLogger) Fatal

func (l *GooseLogger) Fatal(v ...interface{})

func (*GooseLogger) Fatalf

func (l *GooseLogger) Fatalf(msg string, v ...interface{})

func (*GooseLogger) Print

func (l *GooseLogger) Print(v ...interface{})

func (*GooseLogger) Printf

func (l *GooseLogger) Printf(msg string, v ...interface{})

func (*GooseLogger) Println

func (l *GooseLogger) Println(v ...interface{})

type Logger

type Logger struct {
	logr.Logger
}

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

func (*Logger) Verbose

func (l *Logger) Verbose() bool

type Option

type Option func()

func WithZeroLogger

func WithZeroLogger(zlog *zerolog.Logger) Option

type OrganizationDB

type OrganizationDB struct {
	*sqlx.DB
}

func NewOrganizationDB

func NewOrganizationDB(db *sqlx.DB) *OrganizationDB

func (OrganizationDB) Create

func (db OrganizationDB) Create(org *otf.Organization) (*otf.Organization, error)

Create persists a Organization to the DB.

func (OrganizationDB) Delete

func (db OrganizationDB) Delete(name string) error

func (OrganizationDB) Get

func (db OrganizationDB) Get(name string) (*otf.Organization, error)

func (OrganizationDB) List

func (OrganizationDB) Update

func (db OrganizationDB) Update(name string, fn func(*otf.Organization) error) (*otf.Organization, error)

Update persists an updated Organization to the DB. The existing org is fetched from the DB, the supplied func is invoked on the org, and the updated org is persisted back to the DB.

type PlanLogDB

type PlanLogDB struct {
	*sqlx.DB
}

func NewPlanLogDB

func NewPlanLogDB(db *sqlx.DB) *PlanLogDB

func (PlanLogDB) GetChunk

func (db PlanLogDB) GetChunk(ctx context.Context, planID string, opts otf.GetChunkOptions) ([]byte, error)

GetChunk retrieves a log chunk from the DB.

func (PlanLogDB) PutChunk

func (db PlanLogDB) PutChunk(ctx context.Context, planID string, chunk []byte, opts otf.PutChunkOptions) error

PutChunk persists a log chunk to the DB.

type RunDB

type RunDB struct {
	*sqlx.DB
}

func NewRunDB

func NewRunDB(db *sqlx.DB) *RunDB

func (RunDB) Create

func (db RunDB) Create(run *otf.Run) (*otf.Run, error)

Create persists a Run to the DB.

func (RunDB) Delete

func (db RunDB) Delete(id string) error

Delete deletes a run from the DB

func (RunDB) Get

func (db RunDB) Get(opts otf.RunGetOptions) (*otf.Run, error)

Get retrieves a Run domain obj

func (RunDB) List

func (db RunDB) List(opts otf.RunListOptions) (*otf.RunList, error)

func (RunDB) Update

func (db RunDB) Update(opts otf.RunGetOptions, fn func(*otf.Run) error) (*otf.Run, error)

Update persists an updated Run to the DB. The existing run is fetched from the DB, the supplied func is invoked on the run, and the updated run is persisted back to the DB. The returned Run includes any changes, including a new UpdatedAt value.

type StateVersionService

type StateVersionService struct {
	*sqlx.DB
}

func NewStateVersionDB

func NewStateVersionDB(db *sqlx.DB) *StateVersionService

func (StateVersionService) Create

Create persists a StateVersion to the DB.

func (StateVersionService) Delete

func (s StateVersionService) Delete(id string) error

Delete deletes a state version from the DB

func (StateVersionService) Get

func (StateVersionService) List

type StructScannable

type StructScannable interface {
	StructScan(dest interface{}) error
}

type WorkspaceDB

type WorkspaceDB struct {
	*sqlx.DB
}

func NewWorkspaceDB

func NewWorkspaceDB(db *sqlx.DB) *WorkspaceDB

func (WorkspaceDB) Create

func (db WorkspaceDB) Create(ws *otf.Workspace) (*otf.Workspace, error)

Create persists a Workspace to the DB. The returned Workspace is adorned with additional metadata, i.e. CreatedAt, UpdatedAt, etc.

func (WorkspaceDB) Delete

func (db WorkspaceDB) Delete(spec otf.WorkspaceSpecifier) error

Delete deletes a specific workspace, along with its child records (runs etc).

func (WorkspaceDB) Get

func (WorkspaceDB) List

func (WorkspaceDB) Update

func (db WorkspaceDB) Update(spec otf.WorkspaceSpecifier, fn func(*otf.Workspace) error) (*otf.Workspace, error)

Update persists an updated Workspace to the DB. The existing run is fetched from the DB, the supplied func is invoked on the run, and the updated run is persisted back to the DB. The returned Workspace includes any changes, including a new UpdatedAt value.

Jump to

Keyboard shortcuts

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