diff --git a/config/config.go b/config/config.go index e7bd700..63f06f4 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( ) // this is config displayed on the main page -const JTSO_VERSION string = "1.1.0" +const JTSO_VERSION string = "1.1.1" type PortalConfig struct { Https bool diff --git a/gnmicollect/node.go b/gnmicollect/node.go index c7d6642..03f5c7b 100644 --- a/gnmicollect/node.go +++ b/gnmicollect/node.go @@ -1,6 +1,9 @@ package gnmicollect -import "strings" +import ( + "jtso/logger" + "strings" +) type TrieNode struct { children map[string]*TrieNode @@ -124,8 +127,7 @@ func (n *TreeNode) Traverse(f func(node *TreeNode)) { } } -/// For gnmi once only - to auto detect aliasing - +// / For gnmi once only - to auto detect aliasing func Insert(root *TrieNode, base string, xpath string) { // Normalize xpath starting with "./" -> concatenate with the base path @@ -138,20 +140,26 @@ func Insert(root *TrieNode, base string, xpath string) { node := root for _, p := range parts { + if node.children == nil { node.children = make(map[string]*TrieNode) + } if _, ok := node.children[p]; !ok { node.children[p] = &TrieNode{} + } node = node.children[p] node.count++ + } } func CollectPrefixes(node *TrieNode, path []string, result *[]string) { + logger.Log.Infof("DEBUG: Collecting prefixes at node with count %d and path %v", node.count, path) for seg, child := range node.children { - if child.count >= 2 { + logger.Log.Infof("DEBUG: Collecting prefix for segment %s with count %d", seg, child.count) + if child.count >= 1 { // Copy path to avoid slice corruption from append reusing underlying array newPath := make([]string, len(path)+1) copy(newPath, path) @@ -159,6 +167,7 @@ func CollectPrefixes(node *TrieNode, path []string, result *[]string) { stop := false for _, gc := range child.children { + logger.Log.Infof("DEBUG: Checking grandchild %v with count %d", gc, gc.count) if gc.count < 2 { stop = true break diff --git a/gnmicollect/parser.go b/gnmicollect/parser.go index b88a726..acb1d89 100644 --- a/gnmicollect/parser.go +++ b/gnmicollect/parser.go @@ -757,6 +757,7 @@ Loop: rootAlias := &TrieNode{} for _, k := range fieldKeys { + logger.Log.Infof("DEBUG: Field extracted: %s with tags %v", k, fieldMap[k]) f := Field{ Name: k, Monitor: false, @@ -768,6 +769,7 @@ Loop: // to detect alias then Insert(rootAlias, o.Path, k) + logger.Log.Infof("DEBUG: Inserted in Trie with base %s and xpath %s", o.Path, k) } // Provision Alias if found out.