Documentation
¶
Index ¶
- func OpenInterface[T any](ctx context.Context, sql *SQL, table component.Table) (gorm.Interface[T], error)
- type CreateOpts
- type InstanceTable
- type LockTable
- type SQL
- func (sql *SQL) Backup(scontext *component.StagingContext) error
- func (*SQL) BackupName() string
- func (*SQL) Context(parent component.InstallationContext) component.InstallationContext
- func (sql *SQL) CreateDatabase(ctx context.Context, opts CreateOpts) error
- func (sql *SQL) CreateSuperuser(ctx context.Context, user, password string, allowExisting bool) (e error)
- func (sql *SQL) DropDatabase(ctx context.Context, db string) error
- func (sql *SQL) DropUser(ctx context.Context, user string) error
- func (sql *SQL) OpenStack() (component.StackWithResources, error)
- func (sql *SQL) OpenTable(ctx context.Context, table component.Table) (*gorm.DB, error)
- func (sql *SQL) Path() string
- func (sql *SQL) Provision(ctx context.Context, instance models.Instance, domain string) error
- func (sql *SQL) Purge(ctx context.Context, instance models.Instance, domain string) error
- func (sql *SQL) Query(ctx context.Context, query string, args ...interface{}) (e error)
- func (sql *SQL) Shell(ctx context.Context, io stream.IOStream, argv ...string) int
- func (sql *SQL) Snapshot(wisski models.Instance, scontext *component.StagingContext) error
- func (sql *SQL) SnapshotDB(ctx context.Context, progress io.Writer, dest io.Writer, database string) (e error)
- func (*SQL) SnapshotName() string
- func (*SQL) SnapshotNeedsRunning() bool
- func (sql *SQL) Update(ctx context.Context, progress io.Writer) error
- func (sql *SQL) Wait(ctx context.Context) (err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpenInterface ¶
func OpenInterface[T any](ctx context.Context, sql *SQL, table component.Table) (gorm.Interface[T], error)
OpenInterface opens a gorm.Interface to the given sql and table interface. The generic parameter T must correspond to the component.Table's TableInfo.
Types ¶
type CreateOpts ¶
type CreateOpts struct {
Name string // Name of the database to create
AllowExists bool // Don't error if the database already exists
CreateUser bool // Create an appropriate database user
Username string
Password string
}
CreateOpts are options for CreateOpts.
func (CreateOpts) Validate ¶
func (cd CreateOpts) Validate() error
type InstanceTable ¶
func (*InstanceTable) TableInfo ¶
func (*InstanceTable) TableInfo() component.TableInfo
type SQL ¶
type SQL struct {
component.Base
ServerURL string // upstream server url
PollInterval time.Duration // duration to wait for during wait
// contains filtered or unexported fields
}
func (*SQL) Backup ¶
func (sql *SQL) Backup(scontext *component.StagingContext) error
Backup makes a backup of all SQL databases into the path dest.
func (*SQL) BackupName ¶
func (*SQL) Context ¶
func (*SQL) Context(parent component.InstallationContext) component.InstallationContext
func (*SQL) CreateDatabase ¶
func (sql *SQL) CreateDatabase(ctx context.Context, opts CreateOpts) error
CreateDatabase creates a new database with the given name. If the user name is not the empty string, it then generates a new user and grants access to this database.
Provision internally waits for the database to become available.
func (*SQL) CreateSuperuser ¶
func (sql *SQL) CreateSuperuser(ctx context.Context, user, password string, allowExisting bool) (e error)
CreateSuperuser createsa new user, with the name 'user' and the password 'password'. CreateSuperuser always waits for the database to become available, and then uses the internal 'mysql' executable of the container.
func (*SQL) DropDatabase ¶
Drops the given database if it exists.
func (*SQL) OpenTable ¶
OpenTable opens a *gorm.DB connection to the given table. Should use OpenInterface where possible.
TODO: Migrate everything here!
func (*SQL) Shell ¶
Shell directly executes a mysql command inside the container. This command should be used with caution.
func (*SQL) SnapshotDB ¶
func (sql *SQL) SnapshotDB(ctx context.Context, progress io.Writer, dest io.Writer, database string) (e error)
SnapshotDB makes a backup of the sql database into dest.