diff --git a/cli/capabilities.go b/cli/capabilities.go index a972822b1ab086bd3f7ed0c81104c07a861fc526..a80540d873fd52dc582ee6ec124649f64e9ad6b5 100644 --- a/cli/capabilities.go +++ b/cli/capabilities.go @@ -11,7 +11,7 @@ import ( // Capabilities sends a gNMI Capabilities request to the specified target // and prints the supported models to stdout -func Capabilities(a, u , p string) error { +func Capabilities(a, u, p string) error { cfg := gnmi.Config{ Addr: a, Username: u, diff --git a/cli/get.go b/cli/get.go index a0984961c5acd325f8bdefb010ee62c3c224ca41..36dec3a4b75b2c86c225ee7beb71634148c2da39 100644 --- a/cli/get.go +++ b/cli/get.go @@ -9,7 +9,7 @@ import ( ) // Get sends a gNMI Get request to the specified target and prints the response to stdout -func Get(a, u, p string, args...string) error { +func Get(a, u, p string, args ...string) error { sbi := &nucleus.OpenConfig{} opts := &nucleus.GnmiTransportOptions{ Config: gnmi.Config{ diff --git a/cli/init.go b/cli/init.go index 44d5df8ea052f9c138a895dae446259c87024b8f..d85e6bd00885a1c4aefea4b6766da349ccd5b8cd 100644 --- a/cli/init.go +++ b/cli/init.go @@ -8,10 +8,10 @@ import ( var testSchema *ytypes.Schema -func init(){ +func init() { var err error testSchema, err = model.Schema() if err != nil { log.Fatal(err) } -} \ No newline at end of file +} diff --git a/cli/subscribe.go b/cli/subscribe.go index 4306775a9d9614134376c4a8b09915a7d8b947df..bd126534e042cfef33c1ee9dfbf68431a33c7d09 100644 --- a/cli/subscribe.go +++ b/cli/subscribe.go @@ -12,9 +12,10 @@ import ( "syscall" "time" ) + // Subscribe starts a gNMI subscriber requersting the specified paths on the target and // logs the response to stdout. Only 'stream' mode with 'sample' operation supported. -func Subscribe(a, u, p string, sample, heartbeat int64, args...string) error{ +func Subscribe(a, u, p string, sample, heartbeat int64, args ...string) error { sbi := &nucleus.OpenConfig{} tOpts := &nucleus.GnmiTransportOptions{ Config: gnmi.Config{ @@ -27,7 +28,7 @@ func Subscribe(a, u, p string, sample, heartbeat int64, args...string) error{ RespChan: make(chan *gpb.SubscribeResponse), } - device, err := nucleus.NewDevice(sbi,tOpts) + device, err := nucleus.NewDevice(sbi, tOpts) if err != nil { return err } diff --git a/cmd/addDevice.go b/cmd/addDevice.go index c534ec48dc91fd48651c0d4497708f35aae27847..59260a3c6e0b206183652b864ae94665efa8733a 100644 --- a/cmd/addDevice.go +++ b/cmd/addDevice.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/capabilities.go b/cmd/capabilities.go index 623de1c425c80bba4490af218162b9238243a501..fe687884a67b8e7360cac82a7720ae7de3d1cec4 100644 --- a/cmd/capabilities.go +++ b/cmd/capabilities.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -39,7 +40,7 @@ import ( var capabilitiesCmd = &cobra.Command{ Use: "capabilities", Short: "capabilities request", - Long: `Sends a gNMI Capabilities request to the specified target + Long: `Sends a gNMI Capabilities request to the specified target // and prints the supported models to stdout.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Capabilities(username, password, address) diff --git a/cmd/cli.go b/cmd/cli.go index ebe9af89ac336e0d8b737bbc7c9c6e35d85769f2..86e2891e1d21e94b9918205deeab67c895a4111e 100644 --- a/cmd/cli.go +++ b/cmd/cli.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/cliSet.go b/cmd/cliSet.go index 324915c72f906de5bbfd6dea0ab53768d5c3d0e8..a06cf887eb45c7aa62cf37e9607f2ec501820040 100644 --- a/cmd/cliSet.go +++ b/cmd/cliSet.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/get.go b/cmd/get.go index 8cd17622d5c5c62ec7aeaba21932536eac260544..055d6c6f9ee9fb4a94262bc43317336a26a9e6ec 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -39,7 +40,7 @@ import ( var getCmd = &cobra.Command{ Use: "gosdn get", Short: "get request", - Long: `Sends a gNMI Get request to the specified target and prints the response to stdout`, + Long: `Sends a gNMI Get request to the specified target and prints the response to stdout`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Get(address, username, password, args...) }, diff --git a/cmd/getDevice.go b/cmd/getDevice.go index ea4b7271a93abef45649e7372836cb3c9389b16e..7cebe7e81f1e3e49d0ebbaed97d524c9edf059f9 100644 --- a/cmd/getDevice.go +++ b/cmd/getDevice.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/getIds.go b/cmd/getIds.go index adab3025ee9fe37196e2aa35d83aa3624a13b3f0..c729f84b7271c9290a05f28fdaa0f1df12e8ef6e 100644 --- a/cmd/getIds.go +++ b/cmd/getIds.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/gosdn/main.go b/cmd/gosdn/main.go index 03815b4ec592e36599bf2d4bf92aa9f99f91e387..a87c9ff0e98464b7a0c8b1ede5808946d954ca4a 100644 --- a/cmd/gosdn/main.go +++ b/cmd/gosdn/main.go @@ -33,5 +33,5 @@ package main import "code.fbi.h-da.de/cocsn/gosdn/cmd" func main() { - cmd.Execute() + cmd.Execute() } diff --git a/cmd/legacy.go b/cmd/legacy.go index 8d589320f5c19e6df9c6a5df3e8ae6289ecde719..2d90ae0936190e5522171eb91be8b244b1b8224f 100644 --- a/cmd/legacy.go +++ b/cmd/legacy.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -39,7 +40,7 @@ import ( var legacyCmd = &cobra.Command{ Use: "legacy", Short: "multiple ygot utils - not yet implemented", - Long: ``, + Long: ``, RunE: func(cmd *cobra.Command, args []string) error { return errors.New("not implemented") }, diff --git a/cmd/path.go b/cmd/path.go index 0c4b45da9790f81c3574f8410bb32abf7af698c4..abb49047ea79da513743c1cda48b774003725aea 100644 --- a/cmd/path.go +++ b/cmd/path.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -39,7 +40,7 @@ import ( var pathCmd = &cobra.Command{ Use: "path", Short: "multiple ygot utils - not yet implemented", - Long: ``, + Long: ``, RunE: func(cmd *cobra.Command, args []string) error { return errors.New("not implemented") }, diff --git a/cmd/request.go b/cmd/request.go index 9cb4a00ae353c77062caaefaaf26364d8eb092d0..9aaa75f6dc5a087d72a5765c80a1230367b3565c 100644 --- a/cmd/request.go +++ b/cmd/request.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/requestAll.go b/cmd/requestAll.go index d3196783db09b47df0dc8fc51a01c3c5547fbb90..54ee211d911ce138491fa90e9273fa2b86735c03 100644 --- a/cmd/requestAll.go +++ b/cmd/requestAll.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/root.go b/cmd/root.go index 463bdcc35bb1427196a3374add90b5fb0868234f..ca20379fa3ca69fb47da76553dd7e076567ad4bb 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/set.go b/cmd/set.go index 46beef8c98a0fe3bc8647139619036c9a89314d9..0f2b758cd13d23c428a83b6c24cccbe33b56b244 100644 --- a/cmd/set.go +++ b/cmd/set.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -51,6 +52,6 @@ var setCmd = &cobra.Command{ func init() { rootCmd.AddCommand(setCmd) - setCmd.Flags().StringVarP(&typ, "type", "t", "update", "Type of the set request. " + + setCmd.Flags().StringVarP(&typ, "type", "t", "update", "Type of the set request. "+ "Possible values: 'update', 'replace', and 'delete'") } diff --git a/cmd/subscribe.go b/cmd/subscribe.go index 63f58fd72d02f21a7d1dfe9da45819797176e41b..eac7b4518f6e4409759a4f01a037a7b78b893025 100644 --- a/cmd/subscribe.go +++ b/cmd/subscribe.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( diff --git a/cmd/target.go b/cmd/target.go index 2aeb616f72a0c3da13f335301851e3c9d405d22e..97224d87268e43bf3edadfa9368e141efe3148d0 100644 --- a/cmd/target.go +++ b/cmd/target.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -42,7 +43,7 @@ var bindAddr string var targetCmd = &cobra.Command{ Use: "target", Short: "start gnmi target", - Long: `Starts a gNMI target listening on the specified port.`, + Long: `Starts a gNMI target listening on the specified port.`, RunE: func(cmd *cobra.Command, args []string) error { return cli.Target(bindAddr) }, diff --git a/cmd/util.go b/cmd/util.go index c97a75dd988eba3cadc58e020880e57a966bb183..cb2eeb19d92a95250edac97b53b84f9e3431c899 100644 --- a/cmd/util.go +++ b/cmd/util.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -39,7 +40,7 @@ import ( var utilCmd = &cobra.Command{ Use: "util", Short: "multiple ygot utils - not yet implemented", - Long: ``, + Long: ``, RunE: func(cmd *cobra.Command, args []string) error { return errors.New("not implemented") }, diff --git a/cmd/ygot.go b/cmd/ygot.go index 504a4f4f0ef465efd0bdc6e78b5b6fbe6c881657..81ee206ba74db83bbc6e2550b6cde8fe928a9965 100644 --- a/cmd/ygot.go +++ b/cmd/ygot.go @@ -28,6 +28,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package cmd import ( @@ -40,7 +41,7 @@ import ( var ygotCmd = &cobra.Command{ Use: "ygot", Short: "multiple ygot utils - not yet implemented", - Long: ``, + Long: ``, RunE: func(cmd *cobra.Command, args []string) error { return errors.New("not implemented") }, diff --git a/nucleus/integration_test.go b/nucleus/integration_test.go index a4415afceab6db2abba979a0cece8f3c828a3f9c..a31f2ac4622f855dcb1f616361ce045b2d5762a7 100644 --- a/nucleus/integration_test.go +++ b/nucleus/integration_test.go @@ -273,8 +273,8 @@ func TestGnmi_SubscribeIntegration(t *testing.T) { go func() { err = g.Subscribe(ctx) if (err != nil) != tt.wantErr { - if !tt.wantErr{ - if err.Error() != "rpc error: code = Canceled desc = context canceled"{ + if !tt.wantErr { + if err.Error() != "rpc error: code = Canceled desc = context canceled" { t.Errorf("Subscribe() error = %v, wantErr %v", err, tt.wantErr) } } diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go index e46e992bd6c0537168f5d6c8403a80e65d561b58..b28ff911c4e92ca75e3f9cb28908880b78dbf220 100644 --- a/nucleus/southbound_test.go +++ b/nucleus/southbound_test.go @@ -35,8 +35,8 @@ func TestOpenConfig_Id(t *testing.T) { { name: "default", fields: fields{ - schema: nil, - id: ocUUID, + schema: nil, + id: ocUUID, }, want: ocUUID, }, @@ -44,8 +44,8 @@ func TestOpenConfig_Id(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { oc := &OpenConfig{ - schema: tt.fields.schema, - id: tt.fields.id, + schema: tt.fields.schema, + id: tt.fields.id, } if got := oc.Id(); !reflect.DeepEqual(got, tt.want) { t.Errorf("Id() = %v, want %v", got, tt.want) @@ -56,8 +56,8 @@ func TestOpenConfig_Id(t *testing.T) { func TestOpenConfig_SbiIdentifier(t *testing.T) { type fields struct { - schema *ytypes.Schema - id uuid.UUID + schema *ytypes.Schema + id uuid.UUID } tests := []struct { name string @@ -69,8 +69,8 @@ func TestOpenConfig_SbiIdentifier(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { oc := &OpenConfig{ - schema: tt.fields.schema, - id: tt.fields.id, + schema: tt.fields.schema, + id: tt.fields.id, } if got := oc.SbiIdentifier(); got != tt.want { t.Errorf("SbiIdentifier() = %v, want %v", got, tt.want) @@ -85,8 +85,8 @@ func TestOpenConfig_Schema(t *testing.T) { t.Error(err) } type fields struct { - schema *ytypes.Schema - id uuid.UUID + schema *ytypes.Schema + id uuid.UUID } tests := []struct { name string @@ -98,8 +98,8 @@ func TestOpenConfig_Schema(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { oc := &OpenConfig{ - schema: tt.fields.schema, - id: tt.fields.id, + schema: tt.fields.schema, + id: tt.fields.id, } got := oc.Schema().SchemaTree if !reflect.DeepEqual(got, tt.want.SchemaTree) { diff --git a/nucleus/util/path/path_traversal.go b/nucleus/util/path/path_traversal.go index c8951b0731e5579e973964f7e29a61bd1680989b..ada6dbcb1a3439efbcb5b834ec952789e72825e8 100644 --- a/nucleus/util/path/path_traversal.go +++ b/nucleus/util/path/path_traversal.go @@ -8,9 +8,9 @@ import ( "strings" ) -const DELIM = "/" +const delim = "/" -// PathElement represents a node in a path containing its name and possible child nodes +// Element represents a node in a path containing its name and possible child nodes type Element struct { Children []*Element Name string @@ -105,11 +105,11 @@ func appendix(c chan string, stop chan bool, pathChan chan []string) { func stringBuilder(ch chan string, b *strings.Builder, v *Element) { if b.Len() == 0 { - b.WriteString(DELIM) + b.WriteString(delim) } b.WriteString(v.Name) if v.Children != nil { - b.WriteString(DELIM) + b.WriteString(delim) for _, c := range v.Children { var bCpy strings.Builder bCpy.WriteString(b.String()) diff --git a/nucleus/util/proto/message.go b/nucleus/util/proto/message.go index 5057f1f0808f57e408d580f613ef8ab519500503..673be2f9df590416dac904c518d0058a5d31ad40 100644 --- a/nucleus/util/proto/message.go +++ b/nucleus/util/proto/message.go @@ -25,6 +25,8 @@ func Write(message proto.Message, filename string) error { return nil } +// 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) if err != nil {