Merge pull request #178 from kerberos-io/fix/secondary-vault-initialization

Fix/Add kstorage_secondary configuration field and initialize in environment vars
This commit is contained in:
Cédric Verstraeten
2025-04-24 11:59:39 +02:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -98,6 +98,7 @@
"region": "eu-west-1" "region": "eu-west-1"
}, },
"kstorage": {}, "kstorage": {},
"kstorage_secondary": {},
"dropbox": {}, "dropbox": {},
"mqtturi": "tcp://mqtt.kerberos.io:1883", "mqtturi": "tcp://mqtt.kerberos.io:1883",
"mqtt_username": "", "mqtt_username": "",

View File

@@ -183,15 +183,19 @@ func OpenConfig(configDirectory string, configuration *models.Configuration) {
} }
jsonFile.Close() jsonFile.Close()
} }
} }
return return
} }
// This function will override the configuration with environment variables. // This function will override the configuration with environment variables.
func OverrideWithEnvironmentVariables(configuration *models.Configuration) { func OverrideWithEnvironmentVariables(configuration *models.Configuration) {
environmentVariables := os.Environ() environmentVariables := os.Environ()
// Initialize the configuration for some new fields.
if configuration.Config.KStorageSecondary == nil {
configuration.Config.KStorageSecondary = &models.KStorage{}
}
for _, env := range environmentVariables { for _, env := range environmentVariables {
if strings.Contains(env, "AGENT_") { if strings.Contains(env, "AGENT_") {
key := strings.Split(env, "=")[0] key := strings.Split(env, "=")[0]