GNMI plugin should not take off the first character of field keys when no 'alias path' exists. (#8659)

* GNMI plugin should not take off the first character of field keys when no 'alias path' exists.

* fix test method name

* fix test file formatting

* fix test file formatting

* Remove my unnecessary failing test
This commit is contained in:
David Bennett 2021-01-13 15:48:21 -05:00 committed by GitHub
parent 6bd5334f8b
commit fbd54e84a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -290,11 +290,11 @@ func (c *GNMI) handleSubscribeResponseUpdate(address string, response *gnmi.Subs
// Group metrics
for k, v := range fields {
key := k
if len(aliasPath) < len(key) {
if len(aliasPath) < len(key) && len(aliasPath) != 0 {
// This may not be an exact prefix, due to naming style
// conversion on the key.
key = key[len(aliasPath)+1:]
} else {
} else if len(aliasPath) >= len(key) {
// Otherwise use the last path element as the field key.
key = path.Base(key)