provision: Dynamically find components to provision

This commit is contained in:
Tom Wiesing 2022-09-20 19:45:32 +02:00
parent 33cd18e9d9
commit a5d9b1a386
No known key found for this signature in database
5 changed files with 46 additions and 22 deletions

View file

@ -3,17 +3,23 @@ package sql
import (
"errors"
"github.com/FAU-CDI/wisski-distillery/internal/models"
"github.com/FAU-CDI/wisski-distillery/pkg/sqle"
)
var errProvisionInvalidDatabaseParams = errors.New("Provision: Invalid parameters")
var errProvisionInvalidGrant = errors.New("Provision: Grant failed")
// Provision creates a new database with the given name.
// ProvisionInstance provisions sql-specific resource for the given instance
func (sql *SQL) Provision(instance models.Instance, domain string) error {
return sql.CreateDatabase(instance.SqlDatabase, instance.SqlUsername, instance.SqlPassword)
}
// CreateDatabase creates a new database with the given name.
// It then generates a new user, with the name 'user' and the password 'password', that is then granted access to this database.
//
// Provision internally waits for the database to become available.
func (sql *SQL) Provision(name, user, password string) error {
func (sql *SQL) CreateDatabase(name, user, password string) error {
// NOTE(twiesing): We shouldn't use string concat to build sql queries.
// But the driver doesn't support using query params for this particular query.