From 35af96dc3b3b8b1a138d5eacdfdb6b6fbed4f5f1 Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@stud.h-da.de> Date: Thu, 25 Mar 2021 19:59:42 +0100 Subject: [PATCH] fixed linting errors --- cli/http.go | 3 +-- nucleus/errors.go | 16 ++++++++++++++++ nucleus/gnmi_transport.go | 6 +++--- nucleus/restconf_transport.go | 5 +++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/cli/http.go b/cli/http.go index 1dc35dd17..5c1e9e2e2 100644 --- a/cli/http.go +++ b/cli/http.go @@ -40,9 +40,8 @@ func HttpGet(apiEndpoint, f string, args ...string) error { viper.Set("CLI_PND", pnd) viper.Set("CLI_SBI", sbi) return viper.WriteConfig() - } else { - fmt.Println(string(bytes)) } + fmt.Println(string(bytes)) case http.StatusCreated: defer resp.Body.Close() bytes, err := ioutil.ReadAll(resp.Body) diff --git a/nucleus/errors.go b/nucleus/errors.go index 1578ecb16..8bd01fe67 100644 --- a/nucleus/errors.go +++ b/nucleus/errors.go @@ -5,6 +5,7 @@ import ( "reflect" ) +// ErrNilClient implements the Error interface and is called if a GNMI Client is nil. type ErrNilClient struct { } @@ -12,6 +13,7 @@ func (e *ErrNilClient) Error() string { return fmt.Sprintf("client cannot be nil") } +// ErrNil implements the Error interface and is called if a struct is nil. type ErrNil struct { } @@ -19,6 +21,8 @@ func (e *ErrNil) Error() string { return fmt.Sprintf("struct cannot be nil") } +// ErrNotFound implements the Error interface and is called if a specific ID +// of a storable item could not be found. type ErrNotFound struct { id interface{} } @@ -27,6 +31,8 @@ func (e *ErrNotFound) Error() string { return fmt.Sprintf("%v not found", e.id) } +// ErrAlreadyExists implements the Error interface and is called if a specific ID +// of a storable item already exists. type ErrAlreadyExists struct { item interface{} } @@ -35,6 +41,8 @@ func (e *ErrAlreadyExists) Error() string { return fmt.Sprintf("%v already exists", e.item) } +// ErrInvalidTypeAssertion implements the Error interface and is called if the +// type of a storable item does not correspond to the expected type. type ErrInvalidTypeAssertion struct { v interface{} t interface{} @@ -44,6 +52,8 @@ func (e ErrInvalidTypeAssertion) Error() string { return fmt.Sprintf("%v does not implement %v", e.v, e.t) } +// ErrUnsupportedPath implements the Error interface and is called if the +// given path is not supported. type ErrUnsupportedPath struct { p interface{} } @@ -52,12 +62,16 @@ func (e ErrUnsupportedPath) Error() string { return fmt.Sprintf("path %v is not supported", e.p) } +// ErrNotYetImplemented implements the Error interface and is called if a function +// is not implemented yet. type ErrNotYetImplemented struct{} func (e ErrNotYetImplemented) Error() string { return fmt.Sprintf("function not yet implemented") } +// ErrInvalidParameters implements the Error interface and is called if the wrong +// or no parameters have been provided. type ErrInvalidParameters struct { f interface{} r interface{} @@ -67,6 +81,8 @@ func (e ErrInvalidParameters) Error() string { return fmt.Sprintf("invalid parameters for %v: %v", e.f, e.r) } +// ErrInvalidTransportOptions implements the Error interface and is called if the +// wrong TransportOptions have been provided. type ErrInvalidTransportOptions struct { t interface{} } diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index 0f56e38c0..7fb02919e 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -49,8 +49,7 @@ func (g *Gnmi) GetOptions() interface{} { return g.Options } -// Get takes a slice of gnmi paths, splits them and calls a GNMI get for -//each one of them. +// Get takes a slice of gnmi paths, splits them and calls get for each one of them. func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) { if g.client == nil { return nil, &ErrNilClient{} @@ -102,6 +101,7 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) (interface{}, error return g.set(ctx, ops, exts...) } +//Subscribe subscribes to a gNMI target func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error { if g.client == nil { return &ErrNilClient{} @@ -243,7 +243,7 @@ func (g *Gnmi) Close() error { // GnmiTransportOptions implements the TransportOptions interface. // GnmiTransportOptions contains all needed information to setup a Gnmi -// Transport and therefore inherits gnmi.Config. +// transport and therefore inherits gnmi.Config. type GnmiTransportOptions struct { // all needed gnmi transport parameters gnmi.Config diff --git a/nucleus/restconf_transport.go b/nucleus/restconf_transport.go index 606f818ff..c4fc343d4 100644 --- a/nucleus/restconf_transport.go +++ b/nucleus/restconf_transport.go @@ -8,22 +8,27 @@ import ( type Restconf struct { } +//Get not implemented yet func (r Restconf) Get(ctx context.Context, params ...string) (interface{}, error) { return nil, &ErrNotYetImplemented{} } +//Set not implemented yet func (r Restconf) Set(ctx context.Context, params ...string) (interface{}, error) { return nil, &ErrNotYetImplemented{} } +// Subscribe not implemented yet func (r Restconf) Subscribe(ctx context.Context, params ...string) error { return &ErrNotYetImplemented{} } +// Type returns the RESTCONF transport type func (r Restconf) Type() string { return "restconf" } +// ProcessResponse not implemented yet func (r Restconf) ProcessResponse(resp interface{}, root interface{}, models *ytypes.Schema) error { return &ErrNotYetImplemented{} } -- GitLab