mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-30 23:09:23 +02:00
core/config: add support for maps in environments (#4728)
core/config: add support for maps in environments (#4717) Co-authored-by: Caleb Doxsey <cdoxsey@pomerium.com>
This commit is contained in:
parent
c9583c828c
commit
34187e8ba5
3 changed files with 25 additions and 0 deletions
|
@ -528,6 +528,21 @@ func decodeSANMatcherHookFunc() mapstructure.DecodeHookFunc {
|
|||
}
|
||||
}
|
||||
|
||||
func decodeStringToMapHookFunc() mapstructure.DecodeHookFunc {
|
||||
return mapstructure.DecodeHookFuncValue(func(f, t reflect.Value) (any, error) {
|
||||
if f.Kind() != reflect.String || t.Kind() != reflect.Map {
|
||||
return f.Interface(), nil
|
||||
}
|
||||
|
||||
err := json.Unmarshal([]byte(f.Interface().(string)), t.Addr().Interface())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return t.Interface(), nil
|
||||
})
|
||||
}
|
||||
|
||||
// serializable converts mapstructure nested map into map[string]interface{} that is serializable to JSON
|
||||
func serializable(in interface{}) (interface{}, error) {
|
||||
switch typed := in.(type) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue