Documentation
¶
Overview ¶
Package sql implements persistent storage using the sql database.
Index ¶
- Constants
- func FindUpdates(m *reflectx.Mapper, a, b interface{}) map[string]interface{}
- func New(logger logr.Logger, path string, opts ...Option) (*sqlx.DB, error)
- type ApplyLogDB
- type ConfigurationVersionDB
- func (db ConfigurationVersionDB) Create(cv *otf.ConfigurationVersion) (*otf.ConfigurationVersion, error)
- func (db ConfigurationVersionDB) Delete(id string) error
- func (db ConfigurationVersionDB) Get(opts otf.ConfigurationVersionGetOptions) (*otf.ConfigurationVersion, error)
- func (db ConfigurationVersionDB) List(workspaceID string, opts otf.ConfigurationVersionListOptions) (*otf.ConfigurationVersionList, error)
- func (db ConfigurationVersionDB) Update(id string, fn func(*otf.ConfigurationVersion) error) (*otf.ConfigurationVersion, error)
- type Getter
- type GooseLogger
- type Logger
- type Option
- type OrganizationDB
- func (db OrganizationDB) Create(org *otf.Organization) (*otf.Organization, error)
- func (db OrganizationDB) Delete(name string) error
- func (db OrganizationDB) Get(name string) (*otf.Organization, error)
- func (db OrganizationDB) List(opts otf.OrganizationListOptions) (*otf.OrganizationList, error)
- func (db OrganizationDB) Update(name string, fn func(*otf.Organization) error) (*otf.Organization, error)
- type PlanLogDB
- type RunDB
- func (db RunDB) Create(run *otf.Run) (*otf.Run, error)
- func (db RunDB) Delete(id string) error
- func (db RunDB) Get(opts otf.RunGetOptions) (*otf.Run, error)
- func (db RunDB) List(opts otf.RunListOptions) (*otf.RunList, error)
- func (db RunDB) Update(opts otf.RunGetOptions, fn func(*otf.Run) error) (*otf.Run, error)
- type StateVersionService
- func (s StateVersionService) Create(sv *otf.StateVersion) (*otf.StateVersion, error)
- func (s StateVersionService) Delete(id string) error
- func (s StateVersionService) Get(opts otf.StateVersionGetOptions) (*otf.StateVersion, error)
- func (s StateVersionService) List(opts otf.StateVersionListOptions) (*otf.StateVersionList, error)
- type StructScannable
- type WorkspaceDB
- func (db WorkspaceDB) Create(ws *otf.Workspace) (*otf.Workspace, error)
- func (db WorkspaceDB) Delete(spec otf.WorkspaceSpecifier) error
- func (db WorkspaceDB) Get(spec otf.WorkspaceSpecifier) (*otf.Workspace, error)
- func (db WorkspaceDB) List(opts otf.WorkspaceListOptions) (*otf.WorkspaceList, error)
- func (db WorkspaceDB) Update(spec otf.WorkspaceSpecifier, fn func(*otf.Workspace) error) (*otf.Workspace, error)
Constants ¶
const TestDatabaseURL = "OTF_TEST_DATABASE_URL"
Variables ¶
This section is empty.
Functions ¶
func FindUpdates ¶
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'.
Types ¶
type ApplyLogDB ¶
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 ¶
func NewConfigurationVersionDB ¶
func NewConfigurationVersionDB(db *sqlx.DB) *ConfigurationVersionDB
func (ConfigurationVersionDB) Create ¶
func (db ConfigurationVersionDB) Create(cv *otf.ConfigurationVersion) (*otf.ConfigurationVersion, error)
func (ConfigurationVersionDB) Delete ¶
func (db ConfigurationVersionDB) Delete(id string) error
Delete deletes a configuration version from the DB
func (ConfigurationVersionDB) Get ¶
func (db ConfigurationVersionDB) Get(opts otf.ConfigurationVersionGetOptions) (*otf.ConfigurationVersion, error)
func (ConfigurationVersionDB) List ¶
func (db ConfigurationVersionDB) List(workspaceID string, opts otf.ConfigurationVersionListOptions) (*otf.ConfigurationVersionList, error)
func (ConfigurationVersionDB) Update ¶
func (db ConfigurationVersionDB) Update(id string, fn func(*otf.ConfigurationVersion) error) (*otf.ConfigurationVersion, error)
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 GooseLogger ¶
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 OrganizationDB ¶
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 (db OrganizationDB) List(opts otf.OrganizationListOptions) (*otf.OrganizationList, error)
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 ¶
func NewPlanLogDB ¶
type RunDB ¶
type StateVersionService ¶
func NewStateVersionDB ¶
func NewStateVersionDB(db *sqlx.DB) *StateVersionService
func (StateVersionService) Create ¶
func (s StateVersionService) Create(sv *otf.StateVersion) (*otf.StateVersion, error)
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 (s StateVersionService) Get(opts otf.StateVersionGetOptions) (*otf.StateVersion, error)
func (StateVersionService) List ¶
func (s StateVersionService) List(opts otf.StateVersionListOptions) (*otf.StateVersionList, error)
type StructScannable ¶
type StructScannable interface {
StructScan(dest interface{}) error
}
type WorkspaceDB ¶
func NewWorkspaceDB ¶
func NewWorkspaceDB(db *sqlx.DB) *WorkspaceDB
func (WorkspaceDB) Create ¶
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 (db WorkspaceDB) Get(spec otf.WorkspaceSpecifier) (*otf.Workspace, error)
func (WorkspaceDB) List ¶
func (db WorkspaceDB) List(opts otf.WorkspaceListOptions) (*otf.WorkspaceList, error)
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.