Skip to content

Commit e167195

Browse files
authored
fix: token configs & field policies (#108)
1 parent 03bbd29 commit e167195

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

internals/config/loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func Normalize(config *configutils.Config, path string, structure any) {
109109
// Load temporary config back into paths
110110
config.Layer.Delete(path)
111111

112-
config.Load(tmpConf.Layer.All(), path)
112+
config.Load(tmpConf.Layer.Get("").(map[string]any), path)
113113
}
114114

115115
func InitReload() {

internals/config/tokens.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,21 @@ func LoadTokens() {
2727
}
2828

2929
func NormalizeTokens() {
30-
configArray := []map[string]any{}
30+
data := []map[string]any{}
3131

3232
for _, config := range tokenConf.Layer.Slices("tokenconfigs") {
3333
tmpConf := configutils.New()
34-
tmpConf.Load(config.All(), "")
34+
tmpConf.Load(config.Get("").(map[string]any), "")
3535

3636
Normalize(tmpConf, "overrides", &structure.SETTINGS{})
3737

38-
configArray = append(configArray, tmpConf.Layer.All())
38+
data = append(data, tmpConf.Layer.Get("").(map[string]any))
3939
}
4040

4141
// Merge token configs together into new temporary config
42-
tokenConf.Layer.Set("tokenconfigs", configArray)
42+
tokenConf.Load(map[string]any{
43+
"tokenconfigs": data,
44+
}, "")
4345
}
4446

4547
func InitTokens() {

utils/configutils/transform.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,14 @@ func applyTransform(key string, value any, transformTargets map[string]Transform
139139

140140
childKey, childValue := applyTransform(fullKey, v, targets, funcs)
141141

142-
res[childKey] = childValue
142+
keyParts := getKeyParts(childKey)
143+
144+
res[keyParts[len(keyParts)-1]] = childValue
143145
}
144146

145-
return newKey, res
147+
keyParts := getKeyParts(newKey)
148+
149+
return keyParts[len(keyParts)-1], res
146150
case []any:
147151
res := []any{}
148152

@@ -166,7 +170,9 @@ func applyTransform(key string, value any, transformTargets map[string]Transform
166170
res = append(res, childValue)
167171
}
168172

169-
return newKey, res
173+
keyParts := getKeyParts(newKey)
174+
175+
return keyParts[len(keyParts)-1], res
170176
default:
171177
return applyTransformToAny(key, asserted, transformTargets, funcs)
172178
}

utils/request/requestkeys/requestkeys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ var BodyPrefix = "@"
1111
var HeaderPrefix = "#"
1212

1313
func Parse(str string) Field {
14-
prefix := str[1:]
15-
key := str[:1]
14+
prefix := str[:1]
15+
key := str[1:]
1616

1717
return Field{
1818
Prefix: prefix,

0 commit comments

Comments
 (0)