This commit is contained in:
Roy Olav Purser 2022-03-27 14:42:43 +02:00
parent 3c23ee5473
commit 7a72947737
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -44,7 +44,7 @@ func NewConfig() *Config {
if len(splitted) == 2 { if len(splitted) == 2 {
key := cleanKey(splitted[0]) key := cleanKey(splitted[0])
val := splitted[1] val := splitted[1]
splitted = strings.Split(key, "_") splitted = append(strings.Split(key, "_"), "", "", "")
if unicode.IsLetter(getFirstRune(key)) { if unicode.IsLetter(getFirstRune(key)) {
var entry cEntry var entry cEntry
entry.value = val entry.value = val
@ -54,15 +54,16 @@ func NewConfig() *Config {
config.env[key] = entry config.env[key] = entry
if len(splitted) > 1 { if len(splitted) > 1 {
for count, _ := range splitted { for count, _ := range splitted {
left := strings.Join(splitted[:count], "_") if count < len(splitted)-3 {
right := strings.Join(splitted[count:], "_") left := strings.Join(splitted[:count], "_")
if len(config.mapEnv[left]) == 0 { right := strings.Join(splitted[count:], "_")
config.mapEnv[left] = make(map[string]string) if len(config.mapEnv[left]) == 0 {
config.mapMapEnv[left] = make(map[string]map[string]string) config.mapEnv[left] = make(map[string]string)
config.mapMapMapEnv[left] = make(map[string]map[string]map[string]string) config.mapMapEnv[left] = make(map[string]map[string]string)
} config.mapMapMapEnv[left] = make(map[string]map[string]map[string]string)
config.mapEnv[left][right] = key }
if count < len(splitted)-1 { config.mapEnv[left][right] = key
middle := splitted[count] middle := splitted[count]
right = strings.Join(splitted[count+1:], "_") right = strings.Join(splitted[count+1:], "_")
if len(config.mapMapEnv[left][middle]) == 0 { if len(config.mapMapEnv[left][middle]) == 0 {
@ -70,15 +71,14 @@ func NewConfig() *Config {
config.mapMapMapEnv[left][middle] = make(map[string]map[string]string) config.mapMapMapEnv[left][middle] = make(map[string]map[string]string)
} }
config.mapMapEnv[left][middle][right] = key config.mapMapEnv[left][middle][right] = key
if count < len(splitted)-2 {
lmiddle := splitted[count] lmiddle := splitted[count]
rmiddle := splitted[count+1] rmiddle := splitted[count+1]
right = strings.Join(splitted[count+2:], "_") right = strings.Join(splitted[count+2:], "_")
if len(config.mapMapEnv[left][lmiddle][rmiddle]) == 0 { if len(config.mapMapEnv[left][lmiddle][rmiddle]) == 0 {
config.mapMapMapEnv[left][lmiddle][rmiddle] = make(map[string]string) config.mapMapMapEnv[left][lmiddle][rmiddle] = make(map[string]string)
}
config.mapMapMapEnv[left][lmiddle][rmiddle][right] = key
} }
config.mapMapMapEnv[left][lmiddle][rmiddle][right] = key
} }
} }
} }