Documentation
¶
Overview ¶
Package sqlite implements persistent storage using the sqlite database.
Index ¶
- func New(path string, opts ...Option) (*gorm.DB, error)
- type Apply
- type ApplyList
- type ApplyStatusTimestamps
- type ConfigurationVersion
- type ConfigurationVersionDB
- func (db ConfigurationVersionDB) Create(cv *otf.ConfigurationVersion) (*otf.ConfigurationVersion, 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 ConfigurationVersionList
- type Option
- type Organization
- type OrganizationDB
- func (db OrganizationDB) Create(domain *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 tfe.OrganizationListOptions) (*otf.OrganizationList, error)
- func (db OrganizationDB) Update(name string, fn func(*otf.Organization) error) (*otf.Organization, error)
- type OrganizationList
- type Plan
- type PlanList
- type PlanStatusTimestamps
- type Run
- type RunDB
- type RunList
- type RunStatusTimestamps
- type StateVersion
- type StateVersionList
- type StateVersionOutput
- type StateVersionOutputList
- type StateVersionService
- type Workspace
- type WorkspaceDB
- func (db WorkspaceDB) Create(domain *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)
- type WorkspaceList
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Apply ¶
type Apply struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
ResourceAdditions int
ResourceChanges int
ResourceDestructions int
Status tfe.ApplyStatus
StatusTimestamps *ApplyStatusTimestamps `gorm:"embedded;embeddedPrefix:timestamp_"`
LogsBlobID string
// Apply belongs to a run
RunID uint
}
Apply models a row in an applies table.
func (*Apply) FromDomain ¶
FromDomain updates run model fields with a run domain object's fields
type ApplyStatusTimestamps ¶
type ApplyStatusTimestamps struct {
CanceledAt sql.NullTime
ErroredAt sql.NullTime
FinishedAt sql.NullTime
ForceCanceledAt sql.NullTime
QueuedAt sql.NullTime
StartedAt sql.NullTime
}
ApplyStatusTimestamps holds the timestamps for individual apply statuses.
type ConfigurationVersion ¶
type ConfigurationVersion struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
AutoQueueRuns bool
Error string
ErrorMessage string
Source tfe.ConfigurationSource
Speculative bool
Status tfe.ConfigurationStatus
StatusTimestamps *tfe.CVStatusTimestamps `gorm:"embedded;embeddedPrefix:timestamp_"`
// BlobID is the ID of the binary object containing the configuration
BlobID string
// Configuration Version belongs to a Workspace
WorkspaceID uint
Workspace *Workspace
}
ConfigurationVersion models a row in a configuration_versions table.
func (*ConfigurationVersion) FromDomain ¶
func (model *ConfigurationVersion) FromDomain(domain *otf.ConfigurationVersion)
FromDomain updates run model fields with a run domain object's fields
func (*ConfigurationVersion) ToDomain ¶
func (model *ConfigurationVersion) ToDomain() *otf.ConfigurationVersion
func (*ConfigurationVersion) Update ¶
func (model *ConfigurationVersion) Update(fn func(*otf.ConfigurationVersion) error) error
Update updates the model with the supplied fn. The fn operates on the domain obj, so Update handles converting to and from a domain obj.
type ConfigurationVersionDB ¶
func NewConfigurationVersionDB ¶
func NewConfigurationVersionDB(db *gorm.DB) *ConfigurationVersionDB
func (ConfigurationVersionDB) Create ¶
func (db ConfigurationVersionDB) Create(cv *otf.ConfigurationVersion) (*otf.ConfigurationVersion, error)
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 ConfigurationVersionList ¶
type ConfigurationVersionList []ConfigurationVersion
ConfigurationVersionList is a list of run models
func (ConfigurationVersionList) ToDomain ¶
func (l ConfigurationVersionList) ToDomain() (dl []*otf.ConfigurationVersion)
type Option ¶
func WithZeroLogger ¶
type Organization ¶
type Organization struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
Name string
CollaboratorAuthPolicy tfe.AuthPolicyType
CostEstimationEnabled bool
Email string
OwnersTeamSAMLRoleID string
Permissions *tfe.OrganizationPermissions `gorm:"embedded;embeddedPrefix:permission_"`
SAMLEnabled bool
SessionRemember int
SessionTimeout int
TrialExpiresAt time.Time
TwoFactorConformant bool
}
Organization models a row in a organizations table.
func (*Organization) FromDomain ¶
func (model *Organization) FromDomain(org *otf.Organization)
FromDomain updates run model fields with a run domain object's fields
func (*Organization) ToDomain ¶
func (model *Organization) ToDomain() *otf.Organization
func (*Organization) Update ¶
func (model *Organization) Update(fn func(*otf.Organization) error) error
Update updates the model with the supplied fn. The fn operates on the domain obj, so Update handles converting to and from a domain obj.
type OrganizationDB ¶
func NewOrganizationDB ¶
func NewOrganizationDB(db *gorm.DB) *OrganizationDB
func (OrganizationDB) Create ¶
func (db OrganizationDB) Create(domain *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 tfe.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 OrganizationList ¶
type OrganizationList []Organization
OrganizationList is a list of run models
func (OrganizationList) ToDomain ¶
func (l OrganizationList) ToDomain() (dl []*otf.Organization)
type Plan ¶
type Plan struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
ResourceAdditions int
ResourceChanges int
ResourceDestructions int
Status tfe.PlanStatus
StatusTimestamps *PlanStatusTimestamps `gorm:"embedded;embeddedPrefix:timestamp_"`
// The blob ID of the logs
LogsBlobID string
// The blob ID of the execution plan file
PlanFileBlobID string
// The blob ID of the execution plan file in json format
PlanJSONBlobID string
// Plan belongs to a run
RunID uint
}
Plan models a row in a runs table.
func (*Plan) FromDomain ¶
FromDomain updates run model fields with a run domain object's fields
type PlanStatusTimestamps ¶
type PlanStatusTimestamps struct {
CanceledAt sql.NullTime
ErroredAt sql.NullTime
FinishedAt sql.NullTime
ForceCanceledAt sql.NullTime
QueuedAt sql.NullTime
StartedAt sql.NullTime
}
PlanStatusTimestamps holds the timestamps for individual plan statuses.
type Run ¶
type Run struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
ForceCancelAvailableAt time.Time
IsDestroy bool
Message string
Permissions *tfe.RunPermissions `gorm:"embedded;embeddedPrefix:permission_"`
PositionInQueue int
Refresh bool
RefreshOnly bool
Status tfe.RunStatus
StatusTimestamps *RunStatusTimestamps `gorm:"embedded;embeddedPrefix:timestamp_"`
// Comma separated list of replace addresses
ReplaceAddrs string
// Comma separated list of target addresses
TargetAddrs string
// Run has one plan
Plan *Plan
// Run has one apply
Apply *Apply
// Run belongs to a workspace
WorkspaceID uint
Workspace *Workspace
// Run belongs to a configuration version
ConfigurationVersionID uint
ConfigurationVersion *ConfigurationVersion
}
Run models a row in a runs table.
func NewFromDomain ¶
NewFromDomain constructs a model obj from a domain obj
func (*Run) FromDomain ¶
FromDomain updates run model fields with a run domain object's fields
type RunDB ¶
type RunStatusTimestamps ¶
type RunStatusTimestamps struct {
AppliedAt sql.NullTime
ApplyQueuedAt sql.NullTime
ApplyingAt sql.NullTime
CanceledAt sql.NullTime
ConfirmedAt sql.NullTime
CostEstimatedAt sql.NullTime
CostEstimatingAt sql.NullTime
DiscardedAt sql.NullTime
ErroredAt sql.NullTime
ForceCanceledAt sql.NullTime
PlanQueueableAt sql.NullTime
PlanQueuedAt sql.NullTime
PlannedAndFinishedAt sql.NullTime
PlannedAt sql.NullTime
PlanningAt sql.NullTime
PolicyCheckedAt sql.NullTime
PolicySoftFailedAt sql.NullTime
}
type StateVersion ¶
type StateVersion struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
Serial int64
VCSCommitSHA string
VCSCommitURL string
BlobID string
// State version belongs to a workspace
WorkspaceID uint
Workspace *Workspace
// StateVersion has many StateVersionOutput
Outputs []*StateVersionOutput
}
StateVersion models a row in a state versions table.
func (*StateVersion) FromDomain ¶
func (model *StateVersion) FromDomain(domain *otf.StateVersion)
FromDomain updates state version model fields with a state version domain object's fields
func (*StateVersion) ToDomain ¶
func (model *StateVersion) ToDomain() *otf.StateVersion
type StateVersionList ¶
type StateVersionList []StateVersion
func (StateVersionList) ToDomain ¶
func (l StateVersionList) ToDomain() (dl []*otf.StateVersion)
type StateVersionOutput ¶
type StateVersionOutput struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
Name string
Sensitive bool
Type string
Value string
// StateVersionOutput belongs to State Version
StateVersionID uint
}
StateVersionOutput models a row in a state versions table.
func NewStateVersionOutputFromDomain ¶
func NewStateVersionOutputFromDomain(domain *otf.StateVersionOutput) *StateVersionOutput
NewStateVersionOutputFromDomain constructs a model obj from a domain obj
func (*StateVersionOutput) ToDomain ¶
func (model *StateVersionOutput) ToDomain() *otf.StateVersionOutput
type StateVersionOutputList ¶
type StateVersionOutputList []StateVersionOutput
StateVersionOutputList is a list of run models
func (StateVersionOutputList) ToDomain ¶
func (l StateVersionOutputList) ToDomain() (dl []*otf.StateVersionOutput)
type StateVersionService ¶
func NewStateVersionDB ¶
func NewStateVersionDB(db *gorm.DB) *StateVersionService
func (StateVersionService) Create ¶
func (s StateVersionService) Create(sv *otf.StateVersion) (*otf.StateVersion, error)
Create persists a StateVersion to the DB.
func (StateVersionService) Get ¶
func (s StateVersionService) Get(opts otf.StateVersionGetOptions) (*otf.StateVersion, error)
func (StateVersionService) List ¶
func (s StateVersionService) List(opts tfe.StateVersionListOptions) (*otf.StateVersionList, error)
type Workspace ¶
type Workspace struct {
gorm.Model
ExternalID string `gorm:"uniqueIndex"`
AllowDestroyPlan bool
AutoApply bool
CanQueueDestroyPlan bool
Description string
Environment string
ExecutionMode string
FileTriggersEnabled bool
GlobalRemoteState bool
Locked bool
MigrationEnvironment string
Name string
Permissions *tfe.WorkspacePermissions `gorm:"embedded;embeddedPrefix:permission_"`
QueueAllRuns bool
SpeculativeEnabled bool
SourceName string
SourceURL string
StructuredRunOutputEnabled bool
TerraformVersion string
TriggerPrefixes string
VCSRepo *tfe.VCSRepo `gorm:"-"`
WorkingDirectory string
ResourceCount int
ApplyDurationAverage time.Duration
PlanDurationAverage time.Duration
PolicyCheckFailures int
RunFailures int
RunsCount int
OrganizationID uint
Organization *Organization
}
Workspace models a row in a runs table.
func (*Workspace) FromDomain ¶
FromDomain updates workspace model fields with a workspace domain object's fields
type WorkspaceDB ¶
func NewWorkspaceDB ¶
func NewWorkspaceDB(db *gorm.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 associated 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.
type WorkspaceList ¶
type WorkspaceList []Workspace
WorkspaceList is a list of run models
func (WorkspaceList) ToDomain ¶
func (l WorkspaceList) ToDomain() (dl []*otf.Workspace)