Skip to content
Snippets Groups Projects
Commit 35af96dc authored by Malte Bauch's avatar Malte Bauch
Browse files

fixed linting errors

parent ec3f89b8
No related branches found
No related tags found
2 merge requests!120Resolve "Code Quality",!90Develop
Pipeline #67245 passed with warnings
...@@ -40,9 +40,8 @@ func HttpGet(apiEndpoint, f string, args ...string) error { ...@@ -40,9 +40,8 @@ func HttpGet(apiEndpoint, f string, args ...string) error {
viper.Set("CLI_PND", pnd) viper.Set("CLI_PND", pnd)
viper.Set("CLI_SBI", sbi) viper.Set("CLI_SBI", sbi)
return viper.WriteConfig() return viper.WriteConfig()
} else {
fmt.Println(string(bytes))
} }
fmt.Println(string(bytes))
case http.StatusCreated: case http.StatusCreated:
defer resp.Body.Close() defer resp.Body.Close()
bytes, err := ioutil.ReadAll(resp.Body) bytes, err := ioutil.ReadAll(resp.Body)
......
...@@ -5,6 +5,7 @@ import ( ...@@ -5,6 +5,7 @@ import (
"reflect" "reflect"
) )
// ErrNilClient implements the Error interface and is called if a GNMI Client is nil.
type ErrNilClient struct { type ErrNilClient struct {
} }
...@@ -12,6 +13,7 @@ func (e *ErrNilClient) Error() string { ...@@ -12,6 +13,7 @@ func (e *ErrNilClient) Error() string {
return fmt.Sprintf("client cannot be nil") return fmt.Sprintf("client cannot be nil")
} }
// ErrNil implements the Error interface and is called if a struct is nil.
type ErrNil struct { type ErrNil struct {
} }
...@@ -19,6 +21,8 @@ func (e *ErrNil) Error() string { ...@@ -19,6 +21,8 @@ func (e *ErrNil) Error() string {
return fmt.Sprintf("struct cannot be nil") 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 { type ErrNotFound struct {
id interface{} id interface{}
} }
...@@ -27,6 +31,8 @@ func (e *ErrNotFound) Error() string { ...@@ -27,6 +31,8 @@ func (e *ErrNotFound) Error() string {
return fmt.Sprintf("%v not found", e.id) 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 { type ErrAlreadyExists struct {
item interface{} item interface{}
} }
...@@ -35,6 +41,8 @@ func (e *ErrAlreadyExists) Error() string { ...@@ -35,6 +41,8 @@ func (e *ErrAlreadyExists) Error() string {
return fmt.Sprintf("%v already exists", e.item) 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 { type ErrInvalidTypeAssertion struct {
v interface{} v interface{}
t interface{} t interface{}
...@@ -44,6 +52,8 @@ func (e ErrInvalidTypeAssertion) Error() string { ...@@ -44,6 +52,8 @@ func (e ErrInvalidTypeAssertion) Error() string {
return fmt.Sprintf("%v does not implement %v", e.v, e.t) 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 { type ErrUnsupportedPath struct {
p interface{} p interface{}
} }
...@@ -52,12 +62,16 @@ func (e ErrUnsupportedPath) Error() string { ...@@ -52,12 +62,16 @@ func (e ErrUnsupportedPath) Error() string {
return fmt.Sprintf("path %v is not supported", e.p) 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{} type ErrNotYetImplemented struct{}
func (e ErrNotYetImplemented) Error() string { func (e ErrNotYetImplemented) Error() string {
return fmt.Sprintf("function not yet implemented") 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 { type ErrInvalidParameters struct {
f interface{} f interface{}
r interface{} r interface{}
...@@ -67,6 +81,8 @@ func (e ErrInvalidParameters) Error() string { ...@@ -67,6 +81,8 @@ func (e ErrInvalidParameters) Error() string {
return fmt.Sprintf("invalid parameters for %v: %v", e.f, e.r) 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 { type ErrInvalidTransportOptions struct {
t interface{} t interface{}
} }
......
...@@ -49,8 +49,7 @@ func (g *Gnmi) GetOptions() interface{} { ...@@ -49,8 +49,7 @@ func (g *Gnmi) GetOptions() interface{} {
return g.Options return g.Options
} }
// Get takes a slice of gnmi paths, splits them and calls a GNMI get for // Get takes a slice of gnmi paths, splits them and calls get for each one of them.
//each one of them.
func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) { func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) {
if g.client == nil { if g.client == nil {
return nil, &ErrNilClient{} return nil, &ErrNilClient{}
...@@ -102,6 +101,7 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) (interface{}, error ...@@ -102,6 +101,7 @@ func (g *Gnmi) Set(ctx context.Context, args ...interface{}) (interface{}, error
return g.set(ctx, ops, exts...) return g.set(ctx, ops, exts...)
} }
//Subscribe subscribes to a gNMI target
func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error { func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error {
if g.client == nil { if g.client == nil {
return &ErrNilClient{} return &ErrNilClient{}
...@@ -243,7 +243,7 @@ func (g *Gnmi) Close() error { ...@@ -243,7 +243,7 @@ func (g *Gnmi) Close() error {
// GnmiTransportOptions implements the TransportOptions interface. // GnmiTransportOptions implements the TransportOptions interface.
// GnmiTransportOptions contains all needed information to setup a Gnmi // GnmiTransportOptions contains all needed information to setup a Gnmi
// Transport and therefore inherits gnmi.Config. // transport and therefore inherits gnmi.Config.
type GnmiTransportOptions struct { type GnmiTransportOptions struct {
// all needed gnmi transport parameters // all needed gnmi transport parameters
gnmi.Config gnmi.Config
......
...@@ -8,22 +8,27 @@ import ( ...@@ -8,22 +8,27 @@ import (
type Restconf struct { type Restconf struct {
} }
//Get not implemented yet
func (r Restconf) Get(ctx context.Context, params ...string) (interface{}, error) { func (r Restconf) Get(ctx context.Context, params ...string) (interface{}, error) {
return nil, &ErrNotYetImplemented{} return nil, &ErrNotYetImplemented{}
} }
//Set not implemented yet
func (r Restconf) Set(ctx context.Context, params ...string) (interface{}, error) { func (r Restconf) Set(ctx context.Context, params ...string) (interface{}, error) {
return nil, &ErrNotYetImplemented{} return nil, &ErrNotYetImplemented{}
} }
// Subscribe not implemented yet
func (r Restconf) Subscribe(ctx context.Context, params ...string) error { func (r Restconf) Subscribe(ctx context.Context, params ...string) error {
return &ErrNotYetImplemented{} return &ErrNotYetImplemented{}
} }
// Type returns the RESTCONF transport type
func (r Restconf) Type() string { func (r Restconf) Type() string {
return "restconf" return "restconf"
} }
// ProcessResponse not implemented yet
func (r Restconf) ProcessResponse(resp interface{}, root interface{}, models *ytypes.Schema) error { func (r Restconf) ProcessResponse(resp interface{}, root interface{}, models *ytypes.Schema) error {
return &ErrNotYetImplemented{} return &ErrNotYetImplemented{}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment