mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 04:57:33 +00:00
fix: enable env vars in setup steps (and deprecate admin subcommand) (#3871)
* fix: enable env vars in setup steps (and deprecate admin subcommand) * fix tests and error text
This commit is contained in:
28
cmd/initialise/helper.go
Normal file
28
cmd/initialise/helper.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package initialise
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
func exists(query string, args ...interface{}) func(*sql.DB) (exists bool, err error) {
|
||||
return func(db *sql.DB) (exists bool, err error) {
|
||||
row := db.QueryRow("SELECT EXISTS("+query+")", args...)
|
||||
err = row.Scan(&exists)
|
||||
return exists, err
|
||||
}
|
||||
}
|
||||
|
||||
func exec(stmt string, args ...interface{}) func(*sql.DB) error {
|
||||
return func(db *sql.DB) error {
|
||||
_, err := db.Exec(stmt, args...)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func verify(db *sql.DB, checkExists func(*sql.DB) (bool, error), create func(*sql.DB) error) error {
|
||||
exists, err := checkExists(db)
|
||||
if exists || err != nil {
|
||||
return err
|
||||
}
|
||||
return create(db)
|
||||
}
|
Reference in New Issue
Block a user