Skip to content
Snippets Groups Projects

Resolve "A SetRequest to change a specific path of an OND only works for paths with string values"

Compare and
18 files
+ 344
240
Compare changes
  • Side-by-side
  • Inline
Files
18
+ 13
2
@@ -33,6 +33,7 @@ package cmd
import (
"github.com/google/uuid"
gpb "github.com/openconfig/gnmi/proto/gnmi"
"github.com/pterm/pterm"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
@@ -64,9 +65,19 @@ The device UUID and request path must be specified as a positional arguments.`,
}
for _, n := range res.Device {
var panel3 string
panel1 := pterm.DefaultBox.WithTitle("Timestamp:").Sprint(n.GetTimestamp())
panel2 := pterm.DefaultBox.WithTitle("Requested Path:").Sprint(args[1])
panel3 := pterm.DefaultBox.WithTitle("Update:").Sprint(protojson.Format(n.Update[0]))
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{
{{Data: panel1}},
@@ -74,7 +85,7 @@ The device UUID and request path must be specified as a positional arguments.`,
{{Data: panel3}},
}).Srender()
pterm.DefaultBox.WithRightPadding(0).WithBottomPadding(0).Println(panels)
pterm.Info.Println(panels)
}
return nil
},
Loading