Skip to content
Snippets Groups Projects
Commit 97044a5c authored by Manuel Kieweg's avatar Manuel Kieweg
Browse files

moved transport options to proto

parent 418f63cd
Branches
Tags
1 merge request!155Northbound Interface
...@@ -4,9 +4,10 @@ import ( ...@@ -4,9 +4,10 @@ import (
"context" "context"
"reflect" "reflect"
ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
"google.golang.org/grpc" "google.golang.org/grpc"
ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi" "code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors" "code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/types" "code.fbi.h-da.de/cocsn/gosdn/nucleus/types"
......
package nucleus package nucleus
import ( import (
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"context" "context"
"errors" "errors"
"reflect" "reflect"
...@@ -482,6 +483,37 @@ func TestNewGnmiTransport(t *testing.T) { ...@@ -482,6 +483,37 @@ func TestNewGnmiTransport(t *testing.T) {
Compression: "brotli", Compression: "brotli",
}, },
}}}, }}},
<<<<<<< HEAD
=======
want: nil,
wantErr: true,
},
{
name: "certificate error no key file",
args: args{
opts: &tpb.TransportOption{
TransportOption: &tpb.TransportOption_GnmiTransportOption{
GnmiTransportOption: &tpb.GnmiTransportOption{
GrpcDialOptions: map[string]string{
"cert-file":"invalid",
},
},
}}},
want: nil,
wantErr: true,
},
{
name: "certificate error no ca file",
args: args{
opts: &tpb.TransportOption{
TransportOption: &tpb.TransportOption_GnmiTransportOption{
GnmiTransportOption: &tpb.GnmiTransportOption{
GrpcDialOptions: map[string]string{
"ca-file":"invalid",
},
},
}}},
>>>>>>> 55fb68b4 (moved transport options to proto)
want: nil, want: nil,
wantErr: true, wantErr: true,
}, },
...@@ -491,7 +523,11 @@ func TestNewGnmiTransport(t *testing.T) { ...@@ -491,7 +523,11 @@ func TestNewGnmiTransport(t *testing.T) {
if tt.name == "default" { if tt.name == "default" {
startGnmiTarget <- gnmiConfig.Addr startGnmiTarget <- gnmiConfig.Addr
} }
<<<<<<< HEAD
got, err := NewGnmiTransport(tt.args.opts, NewSBI(spb.Type_OPENCONFIG)) got, err := NewGnmiTransport(tt.args.opts, NewSBI(spb.Type_OPENCONFIG))
=======
got, err := NewGnmiTransport(tt.args.opts, &OpenConfig{})
>>>>>>> 55fb68b4 (moved transport options to proto)
if (err != nil) != tt.wantErr { if (err != nil) != tt.wantErr {
t.Errorf("NewGnmiTransport() error = %v, wantErr %v", err, tt.wantErr) t.Errorf("NewGnmiTransport() error = %v, wantErr %v", err, tt.wantErr)
return return
......
...@@ -7,6 +7,8 @@ import ( ...@@ -7,6 +7,8 @@ import (
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport" tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi" "code.fbi.h-da.de/cocsn/gosdn/forks/goarista/gnmi"
"code.fbi.h-da.de/cocsn/gosdn/mocks" "code.fbi.h-da.de/cocsn/gosdn/mocks"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto" "code.fbi.h-da.de/cocsn/gosdn/nucleus/util/proto"
......
package nucleus package nucleus
import ( import (
<<<<<<< HEAD
"context" "context"
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport" tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors" "code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
=======
tpb "code.fbi.h-da.de/cocsn/api/go/gosdn/transport"
"code.fbi.h-da.de/cocsn/gosdn/nucleus/errors"
"context"
>>>>>>> 55fb68b4 (moved transport options to proto)
"github.com/openconfig/ygot/ytypes" "github.com/openconfig/ygot/ytypes"
) )
...@@ -22,12 +28,15 @@ type Transport interface { ...@@ -22,12 +28,15 @@ type Transport interface {
// NewTransport receives TransportOptions and returns an appropriate Transport // NewTransport receives TransportOptions and returns an appropriate Transport
// implementation // implementation
func NewTransport(opts *tpb.TransportOption, sbi SouthboundInterface) (Transport, error) { func NewTransport(opts *tpb.TransportOption, sbi SouthboundInterface) (Transport, error) {
<<<<<<< HEAD
if opts == nil { if opts == nil {
return nil, &errors.ErrInvalidParameters{ return nil, &errors.ErrInvalidParameters{
Func: NewTransport, Func: NewTransport,
Param: "'opt' cannot be 'nil'", Param: "'opt' cannot be 'nil'",
} }
} }
=======
>>>>>>> 55fb68b4 (moved transport options to proto)
switch o := opts.TransportOption.(type) { switch o := opts.TransportOption.(type) {
case *tpb.TransportOption_GnmiTransportOption: case *tpb.TransportOption_GnmiTransportOption:
return NewGnmiTransport(opts, sbi) return NewGnmiTransport(opts, sbi)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment