Move to github.com/tkw1536/pkglib package
This commit removes various modules that can be migrated to the github.com/tkw1536/pkglib package without any code changes (beyond module renamings).
This commit is contained in:
parent
30c25b8e2a
commit
c3ca8e2974
65 changed files with 103 additions and 1254 deletions
|
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
|
||||
"github.com/tkw1536/pkglib/timex"
|
||||
)
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -5,8 +5,8 @@ import (
|
|||
"errors"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/errorx"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/sqle"
|
||||
"github.com/tkw1536/pkglib/errorx"
|
||||
"github.com/tkw1536/pkglib/sqlx"
|
||||
)
|
||||
|
||||
var errProvisionInvalidDatabaseParams = errors.New("Provision: Invalid parameters")
|
||||
|
|
@ -36,7 +36,7 @@ func (sql *SQL) CreateDatabase(ctx context.Context, name, user, password string)
|
|||
// Apparently it's a "feature", see https://github.com/go-sql-driver/mysql/issues/398#issuecomment-169951763.
|
||||
|
||||
// quick and dirty check to make sure that all the names won't sql inject.
|
||||
if !sqle.IsSafeDatabaseLiteral(name) || !sqle.IsSafeDatabaseSingleQuote(user) || !sqle.IsSafeDatabaseSingleQuote(password) {
|
||||
if !sqlx.IsSafeDatabaseLiteral(name) || !sqlx.IsSafeDatabaseSingleQuote(user) || !sqlx.IsSafeDatabaseSingleQuote(password) {
|
||||
return errProvisionInvalidDatabaseParams
|
||||
}
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ func (sql *SQL) CreateSuperuser(ctx context.Context, user, password string, allo
|
|||
// (2) The underlying driver doesn't support "GRANT ALL PRIVILEGES"
|
||||
// See also [sql.Provision].
|
||||
|
||||
if !sqle.IsSafeDatabaseSingleQuote(user) || !sqle.IsSafeDatabaseSingleQuote(password) {
|
||||
if !sqlx.IsSafeDatabaseSingleQuote(user) || !sqlx.IsSafeDatabaseSingleQuote(password) {
|
||||
return errProvisionInvalidDatabaseParams
|
||||
}
|
||||
|
||||
|
|
@ -97,7 +97,7 @@ var errPurgeUser = errors.New("PurgeUser: Failed to drop user")
|
|||
|
||||
// SQLPurgeUser deletes the specified user from the database
|
||||
func (sql *SQL) PurgeUser(ctx context.Context, user string) error {
|
||||
if !sqle.IsSafeDatabaseSingleQuote(user) {
|
||||
if !sqlx.IsSafeDatabaseSingleQuote(user) {
|
||||
return errPurgeUser
|
||||
}
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ var errSQLPurgeDB = errors.New("unable to drop database: unsafe database name")
|
|||
|
||||
// SQLPurgeDatabase deletes the specified db from the database
|
||||
func (sql *SQL) PurgeDatabase(db string) error {
|
||||
if !sqle.IsSafeDatabaseLiteral(db) {
|
||||
if !sqlx.IsSafeDatabaseLiteral(db) {
|
||||
return errSQLPurgeDB
|
||||
}
|
||||
return sql.Exec("DROP DATABASE IF EXISTS `" + db + "`")
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ package sql
|
|||
import (
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/dis/component"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/models"
|
||||
"github.com/tkw1536/goprogram/lib/reflectx"
|
||||
"github.com/tkw1536/pkglib/reflectx"
|
||||
)
|
||||
|
||||
// This file defines additional tables used by multiple components
|
||||
|
|
|
|||
|
|
@ -9,10 +9,10 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/logging"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/sqle"
|
||||
"github.com/FAU-CDI/wisski-distillery/pkg/timex"
|
||||
"github.com/tkw1536/goprogram/exit"
|
||||
"github.com/tkw1536/goprogram/stream"
|
||||
"github.com/tkw1536/pkglib/sqlx"
|
||||
"github.com/tkw1536/pkglib/timex"
|
||||
)
|
||||
|
||||
// Shell runs a mysql shell with the provided databases.
|
||||
|
|
@ -65,7 +65,7 @@ func (sql *SQL) Update(ctx context.Context, progress io.Writer) error {
|
|||
// create the admin user
|
||||
logging.LogMessage(progress, ctx, "Creating sql database")
|
||||
{
|
||||
if !sqle.IsSafeDatabaseLiteral(sql.Config.SQL.Database) {
|
||||
if !sqlx.IsSafeDatabaseLiteral(sql.Config.SQL.Database) {
|
||||
return errSQLUnsafeDatabaseName
|
||||
}
|
||||
createDBSQL := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s`;", sql.Config.SQL.Database)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue