Skip to content

Commit 11d04b2

Browse files
committed
remove temp func
1 parent 9d02e89 commit 11d04b2

File tree

1 file changed

+3
-32
lines changed

1 file changed

+3
-32
lines changed

internals/config/loader.go

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/codeshelldev/secured-signal-api/internals/config/structure"
1414

1515
"github.com/knadh/koanf/parsers/yaml"
16-
"github.com/knadh/koanf/providers/confmap"
1716
)
1817

1918
var ENV *structure.ENV = &structure.ENV{
@@ -83,7 +82,7 @@ func LowercaseKeys(config *configutils.Config) {
8382
}
8483

8584
config.Layer.Delete("")
86-
LoadConfigFromConfigutils(config, data, "")
85+
config.Load(data, "")
8786
}
8887

8988
func NormalizeConfig(config *configutils.Config) {
@@ -103,7 +102,7 @@ func Normalize(config *configutils.Config, path string, structure any) {
103102

104103
// Create temporary config
105104
tmpConf := configutils.New()
106-
LoadConfigFromConfigutils(tmpConf, old, "")
105+
tmpConf.Load(old, "")
107106

108107
// Apply transforms to the new config
109108
tmpConf.ApplyTransformFuncs(structure, "", transformFuncs)
@@ -114,35 +113,7 @@ func Normalize(config *configutils.Config, path string, structure any) {
114113
// Load temporary config back into paths
115114
config.Layer.Delete(path)
116115

117-
LoadConfigFromConfigutils(config, tmpConf.Layer.Get("").(map[string]any), path)
118-
}
119-
120-
func LoadConfigFromConfigutils(config *configutils.Config, data any, path string) error {
121-
parts := strings.Split(path, ".")
122-
123-
log.Debug("Parts: ", parts)
124-
125-
if len(parts) <= 0 {
126-
return errors.New("invalid path")
127-
}
128-
129-
res := map[string]any{}
130-
131-
for i, key := range parts {
132-
if i == 0 {
133-
res[key] = data
134-
} else {
135-
sub := map[string]any{}
136-
137-
sub[key] = res
138-
139-
res = sub
140-
}
141-
}
142-
143-
log.Debug("Res: ", res)
144-
145-
return config.Layer.Load(confmap.Provider(res, "."), nil)
116+
config.Load(tmpConf.Layer.Get("").(map[string]any), path)
146117
}
147118

148119
func InitReload() {

0 commit comments

Comments
 (0)