From 390613e94629234ca367c9a8c21179b71982e958 Mon Sep 17 00:00:00 2001 From: porosnicuadrian Date: Mon, 5 Jul 2021 18:07:09 +0300 Subject: [PATCH] Dumping for all prefixes in agent requests --- agents/agentreq.go | 54 ++++++++++++++++++++++++++++++------ utils/orderednavigablemap.go | 2 +- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/agents/agentreq.go b/agents/agentreq.go index cd818066b..df15d5d29 100644 --- a/agents/agentreq.go +++ b/agents/agentreq.go @@ -105,19 +105,47 @@ func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val interface{}, err } val, err = dp.FieldAsInterface(fldPath[1:]) case utils.MetaReq: - val, err = ar.Request.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.Request.FieldAsInterface(fldPath[1:]) + } else { + val = ar.Request + } case utils.MetaVars: - val, err = ar.Vars.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.Vars.FieldAsInterface(fldPath[1:]) + } else { + val = ar.Vars + } case utils.MetaCgreq: - val, err = ar.CGRRequest.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.CGRRequest.FieldAsInterface(fldPath[1:]) + } else { + val = ar.CGRRequest + } case utils.MetaCgrep: - val, err = ar.CGRReply.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.CGRReply.FieldAsInterface(fldPath[1:]) + } else { + val = ar.CGRReply + } case utils.MetaDiamreq: - val, err = ar.diamreq.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.diamreq.FieldAsInterface(fldPath[1:]) + } else { + val = ar.diamreq + } case utils.MetaRep: - val, err = ar.Reply.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.Reply.FieldAsInterface(fldPath[1:]) + } else { + val = ar.Reply + } case utils.MetaTmp: - val, err = ar.tmp.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.tmp.FieldAsInterface(fldPath[1:]) + } else { + val = ar.tmp + } case utils.MetaUCH: if cacheVal, ok := engine.Cache.Get(utils.CacheUCH, strings.Join(fldPath[1:], utils.NestingSep)); !ok { err = utils.ErrNotFound @@ -125,9 +153,17 @@ func (ar *AgentRequest) FieldAsInterface(fldPath []string) (val interface{}, err val = cacheVal } case utils.MetaOpts: - val, err = ar.Opts.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.Opts.FieldAsInterface(fldPath[1:]) + } else { + val = ar.Opts + } case utils.MetaCfg: - val, err = ar.Cfg.FieldAsInterface(fldPath[1:]) + if len(fldPath) != 1 { + val, err = ar.Cfg.FieldAsInterface(fldPath[1:]) + } else { + val = ar.Cfg + } } if err != nil { return diff --git a/utils/orderednavigablemap.go b/utils/orderednavigablemap.go index 493b89456..b50c9f190 100644 --- a/utils/orderednavigablemap.go +++ b/utils/orderednavigablemap.go @@ -204,7 +204,7 @@ func (onm *OrderedNavigableMap) Append(fullPath *FullPath, val *DataLeaf) (err e return } -// Compose comose the value of the leaf at the given path +// Compose compose the value of the leaf at the given path // this used with full path and the processed path to not calculate them for every set func (onm *OrderedNavigableMap) Compose(fullPath *FullPath, val *DataLeaf) (err error) { if fullPath == nil || len(fullPath.PathSlice) == 0 {