From 79de0a9092f9fa7f9e5f610203a0574353d1b9a9 Mon Sep 17 00:00:00 2001 From: alfred-mk Date: Mon, 6 Jan 2025 14:54:04 +0300 Subject: [PATCH] pass the base directory to load the .env file --- cmd/africastalking/main.go | 4 +++- cmd/async/main.go | 4 +++- cmd/http/main.go | 8 +++++--- cmd/main.go | 4 +++- devtools/gen/main.go | 12 ++++++------ devtools/store/main.go | 13 +++++++------ 6 files changed, 27 insertions(+), 18 deletions(-) diff --git a/cmd/africastalking/main.go b/cmd/africastalking/main.go index dfcaca1..4ca8400 100644 --- a/cmd/africastalking/main.go +++ b/cmd/africastalking/main.go @@ -14,6 +14,7 @@ import ( "git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" + testdataloader "github.com/peteole/testdata-loader" "git.grassecon.net/urdt/ussd/config" "git.grassecon.net/urdt/ussd/initializers" @@ -26,13 +27,14 @@ import ( var ( logg = logging.NewVanilla().WithDomain("AfricasTalking").WithContextKey("at-session-id") + baseDir = testdataloader.GetBasePath() scriptDir = path.Join("services", "registration") build = "dev" menuSeparator = ": " ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } func main() { config.LoadConfig() diff --git a/cmd/async/main.go b/cmd/async/main.go index bf23d9f..51b9e40 100644 --- a/cmd/async/main.go +++ b/cmd/async/main.go @@ -12,6 +12,7 @@ import ( "git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" + testdataloader "github.com/peteole/testdata-loader" "git.grassecon.net/urdt/ussd/config" "git.grassecon.net/urdt/ussd/initializers" @@ -22,12 +23,13 @@ import ( var ( logg = logging.NewVanilla() + baseDir = testdataloader.GetBasePath() scriptDir = path.Join("services", "registration") menuSeparator = ": " ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } type asyncRequestParser struct { diff --git a/cmd/http/main.go b/cmd/http/main.go index 6ddfded..46dbe91 100644 --- a/cmd/http/main.go +++ b/cmd/http/main.go @@ -14,6 +14,7 @@ import ( "git.defalsify.org/vise.git/engine" "git.defalsify.org/vise.git/logging" "git.defalsify.org/vise.git/resource" + testdataloader "github.com/peteole/testdata-loader" "git.grassecon.net/urdt/ussd/config" "git.grassecon.net/urdt/ussd/initializers" @@ -24,13 +25,14 @@ import ( ) var ( - logg = logging.NewVanilla() - scriptDir = path.Join("services", "registration") + logg = logging.NewVanilla() + baseDir = testdataloader.GetBasePath() + scriptDir = path.Join("services", "registration") menuSeparator = ": " ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } func main() { diff --git a/cmd/main.go b/cmd/main.go index 4fd084f..fc6f147 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -15,16 +15,18 @@ import ( "git.grassecon.net/urdt/ussd/internal/handlers" "git.grassecon.net/urdt/ussd/internal/storage" "git.grassecon.net/urdt/ussd/remote" + testdataloader "github.com/peteole/testdata-loader" ) var ( logg = logging.NewVanilla() + baseDir = testdataloader.GetBasePath() scriptDir = path.Join("services", "registration") menuSeparator = ": " ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } func main() { diff --git a/devtools/gen/main.go b/devtools/gen/main.go index b9e2aed..f54afb7 100644 --- a/devtools/gen/main.go +++ b/devtools/gen/main.go @@ -9,22 +9,23 @@ import ( "path" "git.defalsify.org/vise.git/logging" - "git.grassecon.net/urdt/ussd/config" - "git.grassecon.net/urdt/ussd/internal/storage" - "git.grassecon.net/urdt/ussd/initializers" "git.grassecon.net/urdt/ussd/common" + "git.grassecon.net/urdt/ussd/config" + "git.grassecon.net/urdt/ussd/initializers" + "git.grassecon.net/urdt/ussd/internal/storage" + testdataloader "github.com/peteole/testdata-loader" ) var ( logg = logging.NewVanilla() + baseDir = testdataloader.GetBasePath() scriptDir = path.Join("services", "registration") ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } - func main() { config.LoadConfig() @@ -75,5 +76,4 @@ func main() { fmt.Fprintf(os.Stderr, err.Error()) os.Exit(1) } - } diff --git a/devtools/store/main.go b/devtools/store/main.go index 8bd4d16..9f3e196 100644 --- a/devtools/store/main.go +++ b/devtools/store/main.go @@ -7,24 +7,25 @@ import ( "os" "path" - "git.grassecon.net/urdt/ussd/config" - "git.grassecon.net/urdt/ussd/initializers" - "git.grassecon.net/urdt/ussd/internal/storage" - "git.grassecon.net/urdt/ussd/debug" "git.defalsify.org/vise.git/db" "git.defalsify.org/vise.git/logging" + "git.grassecon.net/urdt/ussd/config" + "git.grassecon.net/urdt/ussd/debug" + "git.grassecon.net/urdt/ussd/initializers" + "git.grassecon.net/urdt/ussd/internal/storage" + testdataloader "github.com/peteole/testdata-loader" ) var ( logg = logging.NewVanilla() + baseDir = testdataloader.GetBasePath() scriptDir = path.Join("services", "registration") ) func init() { - initializers.LoadEnvVariables() + initializers.LoadEnvVariables(baseDir) } - func main() { config.LoadConfig()