diff --git a/cli/cmd/changeList.go b/cli/cmd/changeList.go index af52241337c28aacfcbb372493fb9fba9953beb2..eb2c111e396cd9ba4e41b018425df56b654a99aa 100644 --- a/cli/cmd/changeList.go +++ b/cli/cmd/changeList.go @@ -68,7 +68,11 @@ var changeListCmd = &cobra.Command{ } spinner.Success() - pterm.DefaultTable.WithHasHeader().WithData(data).Render() + err = pterm.DefaultTable.WithHasHeader().WithData(data).Render() + if err != nil { + return err + } + return nil }, } diff --git a/cli/cmd/deviceList.go b/cli/cmd/deviceList.go index c74939942fd69fa3411cde5301189b4d9d1afde7..9fc5247f3af6dff3d7df99c6021af666428aeaf3 100644 --- a/cli/cmd/deviceList.go +++ b/cli/cmd/deviceList.go @@ -60,7 +60,11 @@ var deviceListCmd = &cobra.Command{ spinner.Success() - pterm.DefaultTable.WithHasHeader().WithData(data).Render() + err = pterm.DefaultTable.WithHasHeader().WithData(data).Render() + if err != nil { + return err + } + return nil }, } diff --git a/cli/cmd/pndList.go b/cli/cmd/pndList.go index 65006b0c7705f8896abd7c81900420a23be2bee4..b0e46360a28d79173aad457d701fda00b91a1110 100644 --- a/cli/cmd/pndList.go +++ b/cli/cmd/pndList.go @@ -60,7 +60,11 @@ var pndListCmd = &cobra.Command{ spinner.Success() - pterm.DefaultTable.WithHasHeader().WithData(data).Render() + err = pterm.DefaultTable.WithHasHeader().WithData(data).Render() + if err != nil { + return err + } + return nil }, } diff --git a/cli/cmd/root.go b/cli/cmd/root.go index bf5c804082d791d811db3f991fb88f40ed0ba1ce..00206c1fa3dadd7469ed0ee8360bb3aa822aeb40 100644 --- a/cli/cmd/root.go +++ b/cli/cmd/root.go @@ -67,7 +67,10 @@ The login command must be called for authorization. // Execute adds all child commands to the root command and sets flags appropriately. // This is called by main.main(). It only needs to happen once to the rootCmd. func Execute() { - rootCmd.Execute() + err := rootCmd.Execute() + if err != nil { + log.Error("Could not execute root command: ", err) + } //cobra.CheckErr(rootCmd.Execute()) } diff --git a/controller/api/device.go b/controller/api/device.go index 9ac80f41bf95713d42959155e1dc51c7d161ab58..22f51cf7d71e4330fa9c4e061f19b74083dbdd44 100644 --- a/controller/api/device.go +++ b/controller/api/device.go @@ -100,7 +100,12 @@ func GetSbiSchemaTree(ctx context.Context, addr string, pid, sid uuid.UUID) (map break } log.Error(err) - sClient.CloseSend() + + closeErr := sClient.CloseSend() + if closeErr != nil { + return nil, err + } + return map[string]*yang.Entry{}, err } sTreeBytes = append(sTreeBytes, payload.Chunk...) diff --git a/controller/nucleus/principalNetworkDomain.go b/controller/nucleus/principalNetworkDomain.go index ad4b601c74e6ad6fad5b0681ebc66fa2beb375ca..d187955708cce58f21c09e0b522436126999a8ee 100644 --- a/controller/nucleus/principalNetworkDomain.go +++ b/controller/nucleus/principalNetworkDomain.go @@ -86,7 +86,11 @@ func NewPND( if len(existingSBIs) == 0 { newSBI, _ := NewSBI(spb.Type_TYPE_OPENCONFIG) - pnd.sbic.Add(newSBI) + err = pnd.sbic.Add(newSBI) + + if err != nil { + return nil, err + } } return pnd, nil @@ -717,7 +721,6 @@ func saveGenericClientStreamToFile(t GenericGrpcClient, filename string, id uuid if err == io.EOF { break } - t.CloseSend() closeErr := t.CloseSend() if closeErr != nil { return uuid.Nil, closeErr @@ -727,7 +730,6 @@ func saveGenericClientStreamToFile(t GenericGrpcClient, filename string, id uuid } n, err := f.Write(payload.Chunk) if err != nil { - t.CloseSend() closeErr := t.CloseSend() if closeErr != nil { return uuid.Nil, closeErr diff --git a/controller/nucleus/util/proto/message.go b/controller/nucleus/util/proto/message.go index 066c0434e96fab416ffd4511e7101fdd31208165..cda7787d7ebf80b0ea1ca936deef79d995dc3d6a 100644 --- a/controller/nucleus/util/proto/message.go +++ b/controller/nucleus/util/proto/message.go @@ -3,6 +3,7 @@ package proto import ( "fmt" "io/ioutil" + "path/filepath" "google.golang.org/protobuf/proto" ) @@ -29,7 +30,7 @@ func Write(message proto.Message, filename string) error { // Read reads a binary file (containing a marshaled protocol buffer message) // and unmarshals it back into a protocol buffer message func Read(filename string, message proto.Message) error { - data, err := ioutil.ReadFile(filename) + data, err := ioutil.ReadFile(filepath.Clean(filename)) if err != nil { return fmt.Errorf("cannot read binary data from file: %w", err) }