Skip to content
Snippets Groups Projects
Commit 0af8cb63 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

Fix issue when trying to access empty gnmi notification in CLI

See merge request !398
parent d67ce292
No related branches found
No related tags found
2 merge requests!398Fix issue when trying to access empty gnmi notification in CLI,!382Develop
Pipeline #122128 failed
......@@ -69,14 +69,18 @@ The network element UUID and request path must be specified as a positional argu
panel1 := pterm.DefaultBox.WithTitle("Timestamp:").Sprint(n.GetTimestamp())
panel2 := pterm.DefaultBox.WithTitle("Requested Path:").Sprint(args[1])
val := n.Update[0].GetVal()
switch valTyped := val.GetValue().(type) {
case *gpb.TypedValue_JsonIetfVal:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(string(valTyped.JsonIetfVal))
case *gpb.TypedValue_JsonVal:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(string(valTyped.JsonVal))
default:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(protojson.Format(val))
if len(n.Update) == 0 {
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint("empty value")
} else {
val := n.Update[0].GetVal()
switch valTyped := val.GetValue().(type) {
case *gpb.TypedValue_JsonIetfVal:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(string(valTyped.JsonIetfVal))
case *gpb.TypedValue_JsonVal:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(string(valTyped.JsonVal))
default:
panel3 = pterm.DefaultBox.WithTitle("Update:").Sprint(protojson.Format(val))
}
}
panels, _ := pterm.DefaultPanel.WithPanels(pterm.Panels{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment