Correct override handling for mode

This commit is contained in:
lash 2025-01-22 16:40:32 +00:00
parent 1909b60bf4
commit 5e83c89e03
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
7 changed files with 12 additions and 15 deletions

View File

@ -36,12 +36,10 @@ func main() {
var err error var err error
var gettextDir string var gettextDir string
var langs args.LangVar var langs args.LangVar
var resourceDir string
flag.StringVar(&sessionId, "session-id", "075xx2123", "session id") flag.StringVar(&sessionId, "session-id", "075xx2123", "session id")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory") flag.StringVar(override.ResourceConn, "resource", "?", "resource data directory")
flag.StringVar(&resourceDir, "resource-dir", "", "resource data directory. If set, overrides --resource to create a non-binary fsdb for the given path.")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
flag.StringVar(override.StateConn, "state", "?", "state store connection string") flag.StringVar(override.StateConn, "state", "?", "state store connection string")
flag.BoolVar(&engineDebug, "d", false, "use engine debug output") flag.BoolVar(&engineDebug, "d", false, "use engine debug output")
@ -50,10 +48,6 @@ func main() {
flag.Var(&langs, "language", "add symbol resolution for language") flag.Var(&langs, "language", "add symbol resolution for language")
flag.Parse() flag.Parse()
if resourceDir != "" {
*override.ResourceConn = resourceDir
override.ResourceConnMode = storage.DBMODE_TEXT
}
config.Apply(override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {

View File

@ -31,14 +31,13 @@ var (
func main() { func main() {
config.LoadConfig() config.LoadConfig()
var override config.Override override := config.NewOverride()
var authConnStr string var authConnStr string
var size uint var size uint
var engineDebug bool var engineDebug bool
var stateDebug bool var stateDebug bool
var host string var host string
var port uint var port uint
//flag.StringVar(&authConnStr, "authdb", "", "auth connection string")
flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)") flag.StringVar(override.DbConn, "c", "?", "default connection string (replaces all unspecified strings)")
flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string") flag.StringVar(override.ResourceConn, "resource", "?", "resource connection string")
flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string") flag.StringVar(override.UserConn, "userdata", "?", "userdata store connection string")
@ -49,7 +48,7 @@ func main() {
flag.UintVar(&port, "p", config.PortSSH(), "socket port") flag.UintVar(&port, "p", config.PortSSH(), "socket port")
flag.Parse() flag.Parse()
config.Apply(&override) config.Apply(override)
conns, err := config.GetConns() conns, err := config.GetConns()
if err != nil { if err != nil {
fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err) fmt.Fprintf(os.Stderr, "conn specification error: %v\n", err)

View File

@ -2,6 +2,7 @@ package config
import ( import (
viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config" viseconfig "git.grassecon.net/grassrootseconomics/visedriver/config"
"git.grassecon.net/grassrootseconomics/visedriver/storage"
) )
func NewOverride() *viseconfig.Override { func NewOverride() *viseconfig.Override {
@ -12,8 +13,11 @@ func NewOverride() *viseconfig.Override {
o := &viseconfig.Override{ o := &viseconfig.Override{
DbConn: &a, DbConn: &a,
StateConn: &b, StateConn: &b,
StateConnMode: storage.DBMODE_TEXT,
ResourceConn: &c, ResourceConn: &c,
ResourceConnMode: storage.DBMODE_TEXT,
UserConn: &d, UserConn: &d,
UserConnMode: storage.DBMODE_BINARY,
} }
return o return o
} }

2
go.mod
View File

@ -6,7 +6,7 @@ require (
git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9 git.defalsify.org/vise.git v0.2.3-0.20250120121301-10739fb4a8c9
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84
github.com/alecthomas/assert/v2 v2.2.2 github.com/alecthomas/assert/v2 v2.2.2
github.com/gofrs/uuid v4.4.0+incompatible github.com/gofrs/uuid v4.4.0+incompatible

4
go.sum
View File

@ -4,8 +4,8 @@ git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d
git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60= git.grassecon.net/grassrootseconomics/common v0.0.0-20250121134736-ba8cbbccea7d/go.mod h1:wgQJZGIS6QuNLHqDhcsvehsbn5PvgV7aziRebMnJi60=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805 h1:deGnqf4YCsbxhXgjFEjYjTUCvciLEmI26T9IysRsQXY=
git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8= git.grassecon.net/grassrootseconomics/sarafu-api v0.0.0-20250121135150-e0b539809805/go.mod h1:9bc3d//Qqm11hz7GYRdQc1Uan+0GJIOpvRBbv8cHMu8=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a h1:g0epqAJvHdOvzdGNfH0ZmZ6QKsbcybOroLnYi78ZnDo= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2 h1:ON77G5K0JNuwPb5JT/hRfF6G6+xstlBQgEIEzWydnhg=
git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122093711-8530c450741a/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk= git.grassecon.net/grassrootseconomics/visedriver v0.8.0-beta.10.0.20250122123424-6749c632b0a2/go.mod h1:pjKp9L/ZsWW3kMB0UoIl1yv9TBIuU33mn9Aghxp7vGk=
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84 h1:VoBmqsjlRdz+IPbtKsAkc1IrMepjR+QlesZT31Jokrk=
git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ= git.grassecon.net/grassrootseconomics/visedriver-africastalking v0.0.0-20250121135340-ca97e23e8c84/go.mod h1:DpibtYpnT3nG4Kn556hRAkdu4+CtiI/6MbnQHal51mQ=
github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk= github.com/alecthomas/assert/v2 v2.2.2 h1:Z/iVC0xZfWTaFNE6bA3z07T86hd45Xe2eLt6WVy2bbk=

View File

@ -32,7 +32,7 @@ func CleanDatabase() {
if conn.DbType() == storage.DBTYPE_POSTGRES { if conn.DbType() == storage.DBTYPE_POSTGRES {
ctx := context.Background() ctx := context.Background()
// Update the connection string with the new search path // Update the connection string with the new search path
updatedConnStr := conn.String() updatedConnStr := conn.Raw()
dbConn, err := pgxpool.New(ctx, updatedConnStr) dbConn, err := pgxpool.New(ctx, updatedConnStr)
if err != nil { if err != nil {
@ -62,7 +62,7 @@ func CleanDatabase() {
func TestEngine(sessionId string) (engine.Engine, func(), chan bool) { func TestEngine(sessionId string) (engine.Engine, func(), chan bool) {
config.LoadConfig() config.LoadConfig()
err := config.Apply(&override) err := config.Apply(override)
if err != nil { if err != nil {
panic(fmt.Errorf("args override fail: %v\n", err)) panic(fmt.Errorf("args override fail: %v\n", err))
} }

View File

@ -18,7 +18,7 @@ var (
resourceDb db.Db resourceDb db.Db
baseDir = testdataloader.GetBasePath() baseDir = testdataloader.GetBasePath()
scriptDir = path.Join(baseDir, "services", "registration") scriptDir = path.Join(baseDir, "services", "registration")
override config.Override override = config.NewOverride()
) )
func init() { func init() {