fixed printconfig bug

This commit is contained in:
jay brown
2025-03-18 15:52:58 -07:00
parent 31082c0ff5
commit 3fef82354a
5 changed files with 116 additions and 127 deletions
+20 -34
View File
@@ -2,46 +2,32 @@ package main
import (
"fmt"
"os"
"sort"
"log"
"queryorchestration/internal/rbac" // Replace with your actual module name
"queryorchestration/internal/serviceconfig"
)
//type DummyServiceConfig struct {
// service.BaseConfig
//}
func PrintEnvironmentVariables() {
// Get all environment variables
envVars := os.Environ()
// Sort them for consistent output
sort.Strings(envVars)
// Print each variable in "key = value" format
for _, env := range envVars {
// Find the first equals sign to split the string
for i := 0; i < len(env); i++ {
if env[i] == '=' {
key := env[:i]
value := env[i+1:]
fmt.Printf("%s = %s\n", key, value)
break
}
}
}
}
// for testing run like `LOG_LEVEL=INFO go run main.go`
func main() {
PrintEnvironmentVariables()
//cfg := &DummyServiceConfig{}
//errGettingConfig := serviceconfig.InitializeConfig(cfg)
//if errGettingConfig != nil {
// log.Fatal(errGettingConfig)
//}
cfg := &serviceconfig.BaseConfig{}
errGettingConfig := serviceconfig.InitializeConfig(cfg)
if errGettingConfig != nil {
log.Fatal(errGettingConfig)
}
errorInitializingAuthProvider := cfg.InitializeAuthProvider()
if errorInitializingAuthProvider != nil {
log.Fatal(errorInitializingAuthProvider)
}
cfg.PrintConfig("secret")
// use the config here for the key provider parameters
// Example with local key provider for testing
if cfg.AuthProvider == nil {
log.Fatal("AuthProvider is nil")
}
localProvider := rbac.NewLocalKeyProvider("private_key.pem", "public_key.pem")
// Generate a mock JWT with multiple Cognito groups