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