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

lint error fixes (mainly commenting)

parent 59aec7f3
No related branches found
No related tags found
2 merge requests!120Resolve "Code Quality",!90Develop
...@@ -61,6 +61,7 @@ func createSouthboundInterfaces() error { ...@@ -61,6 +61,7 @@ func createSouthboundInterfaces() error {
return nil return nil
} }
// Run calls initialize to start the controller
func Run(ctx context.Context) error { func Run(ctx context.Context) error {
if err := initialize(ctx); err != nil { if err := initialize(ctx); err != nil {
log.WithFields(log.Fields{}).Error(err) log.WithFields(log.Fields{}).Error(err)
......
...@@ -5,6 +5,8 @@ import ( ...@@ -5,6 +5,8 @@ import (
"github.com/openconfig/ygot/ygot" "github.com/openconfig/ygot/ygot"
) )
// Device represents an Orchestrated Network Device (OND) which is managed by
// nucleus
type Device struct { type Device struct {
// Uuid represents the Devices UUID // Uuid represents the Devices UUID
Uuid uuid.UUID Uuid uuid.UUID
...@@ -19,7 +21,7 @@ type Device struct { ...@@ -19,7 +21,7 @@ type Device struct {
Transport Transport Transport Transport
} }
//NewDevice creates a Device // NewDevice creates a Device
func NewDevice(sbi SouthboundInterface, opts TransportOptions) (*Device, error) { func NewDevice(sbi SouthboundInterface, opts TransportOptions) (*Device, error) {
var transport Transport var transport Transport
var err error var err error
...@@ -41,6 +43,7 @@ func NewDevice(sbi SouthboundInterface, opts TransportOptions) (*Device, error) ...@@ -41,6 +43,7 @@ func NewDevice(sbi SouthboundInterface, opts TransportOptions) (*Device, error)
}, nil }, nil
} }
// Id returns the uuid of the Device
func (d *Device) Id() uuid.UUID { func (d *Device) Id() uuid.UUID {
return d.Uuid return d.Uuid
} }
...@@ -19,6 +19,8 @@ type Gnmi struct { ...@@ -19,6 +19,8 @@ type Gnmi struct {
client gpb.GNMIClient client gpb.GNMIClient
} }
// NewGnmiTransport takes a struct of GnmiTransportOptions and returns a Gnmi
// transport based on the values of it.
func NewGnmiTransport(opts *GnmiTransportOptions) (*Gnmi, error) { func NewGnmiTransport(opts *GnmiTransportOptions) (*Gnmi, error) {
c, err := gnmi.Dial(&opts.Config) c, err := gnmi.Dial(&opts.Config)
if err != nil { if err != nil {
...@@ -37,18 +39,18 @@ func NewGnmiTransport(opts *GnmiTransportOptions) (*Gnmi, error) { ...@@ -37,18 +39,18 @@ func NewGnmiTransport(opts *GnmiTransportOptions) (*Gnmi, error) {
}, nil }, nil
} }
//SetConfig sets the config of gnmi //SetOptions sets Gnmi Options
func (g *Gnmi) SetOptions(to TransportOptions) { func (g *Gnmi) SetOptions(to TransportOptions) {
g.Options = to.(*GnmiTransportOptions) g.Options = to.(*GnmiTransportOptions)
} }
//GetConfig returns the gnmi config //GetOptions returns the Gnmi options
func (g *Gnmi) GetOptions() interface{} { func (g *Gnmi) GetOptions() interface{} {
return g.Options return g.Options
} }
// interface satisfaction for now // Get takes a slice of gnmi paths, splits them and calls a GNMI get for
// TODO: Convert to meaningfiul calls //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{}
...@@ -107,6 +109,7 @@ func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error { ...@@ -107,6 +109,7 @@ func (g *Gnmi) Subscribe(ctx context.Context, params ...string) error {
return g.subscribe(ctx) return g.subscribe(ctx)
} }
// Type returns the gNMI transport type
func (g *Gnmi) Type() string { func (g *Gnmi) Type() string {
return "gnmi" return "gnmi"
} }
...@@ -238,6 +241,9 @@ func (g *Gnmi) Close() error { ...@@ -238,6 +241,9 @@ func (g *Gnmi) Close() error {
return nil return nil
} }
// GnmiTransportOptions implements the TransportOptions interface.
// GnmiTransportOptions contains all needed information to setup a Gnmi
// 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
...@@ -248,14 +254,24 @@ type GnmiTransportOptions struct { ...@@ -248,14 +254,24 @@ type GnmiTransportOptions struct {
RespChan chan *gpb.SubscribeResponse RespChan chan *gpb.SubscribeResponse
} }
// GetAddress returns the address used by the transport to connect to a
// gRPC endpoint.
func (gto *GnmiTransportOptions) GetAddress() string { func (gto *GnmiTransportOptions) GetAddress() string {
return gto.Addr return gto.Config.Addr
} }
// GetUsername returns the username used by the transport to connect to a
// gRPC endpoint.
func (gto *GnmiTransportOptions) GetUsername() string { func (gto *GnmiTransportOptions) GetUsername() string {
return gto.Username return gto.Config.Username
} }
// GetPassword returns the password used by the transport to connect to a
// gRPC endpoint.
func (gto *GnmiTransportOptions) GetPassword() string { func (gto *GnmiTransportOptions) GetPassword() string {
return gto.Password return gto.Config.Password
} }
// IsTransportOption is needed to fulfill the requirements of the
// TransportOptions interface. It does not need any further implementation.
func (gto *GnmiTransportOptions) IsTransportOption() {} func (gto *GnmiTransportOptions) IsTransportOption() {}
...@@ -26,6 +26,7 @@ type SouthboundInterface interface { ...@@ -26,6 +26,7 @@ type SouthboundInterface interface {
Id() uuid.UUID Id() uuid.UUID
} }
// Tapi is the implementation of an TAPI SBI.
type Tapi struct { type Tapi struct {
} }
...@@ -44,6 +45,7 @@ func (oc *OpenConfig) SbiIdentifier() string { ...@@ -44,6 +45,7 @@ func (oc *OpenConfig) SbiIdentifier() string {
return "openconfig" return "openconfig"
} }
// Schema returns a ygot generated openconfig Schema as ytypes.Schema
func (oc *OpenConfig) Schema() *ytypes.Schema { func (oc *OpenConfig) Schema() *ytypes.Schema {
schema, err := openconfig.Schema() schema, err := openconfig.Schema()
oc.schema = schema oc.schema = schema
...@@ -145,6 +147,7 @@ func iter(a ygot.GoStruct, fields []string) (b ygot.GoStruct, f string, err erro ...@@ -145,6 +147,7 @@ func iter(a ygot.GoStruct, fields []string) (b ygot.GoStruct, f string, err erro
return return
} }
// Id returns the Id of the OpenConfig SBI
func (oc *OpenConfig) Id() uuid.UUID { func (oc *OpenConfig) Id() uuid.UUID {
return oc.id return oc.id
} }
...@@ -31,6 +31,8 @@ func (yc YANGConsumer) Consume(reader io.Reader, _ interface{}) error { ...@@ -31,6 +31,8 @@ func (yc YANGConsumer) Consume(reader io.Reader, _ interface{}) error {
return err return err
} }
// TransportOptions provides an interface for TransportOptions implementations
// for Transports like RESTCONF or gNMI
type TransportOptions interface { type TransportOptions interface {
GetAddress() string GetAddress() string
GetUsername() string GetUsername() string
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment