From 9be63670a646cd48f4f6d7282d2e17b27d0d1197 Mon Sep 17 00:00:00 2001 From: Malte Bauch <malte.bauch@stud.h-da.de> Date: Thu, 3 Mar 2022 15:23:30 +0100 Subject: [PATCH] Linter pleasing --- api/grpc.go | 5 ++++- api/initialise_test.go | 3 ++- controller.go | 4 ++-- northbound/server/core.go | 1 - northbound/server/pnd.go | 4 ---- northbound/server/pnd_test.go | 7 ++++--- nucleus/southbound.go | 1 - 7 files changed, 12 insertions(+), 13 deletions(-) diff --git a/api/grpc.go b/api/grpc.go index d3a3a6d46..a9ef08f46 100644 --- a/api/grpc.go +++ b/api/grpc.go @@ -15,13 +15,14 @@ import ( "github.com/spf13/viper" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" ) var dialOptions []grpc.DialOption func init() { dialOptions = []grpc.DialOption{ - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), } } @@ -232,6 +233,8 @@ func getDevice(addr, pid string, did ...string) (*ppb.GetOndResponse, error) { return pndClient.GetOnd(ctx, req) } +//nolint +// NOTE: currently not in use, but could be of value later // getDevice requests all devices belonging to a given // PrincipalNetworkDomain from the controller. func getDevices(addr, pid string) (*ppb.GetOndListResponse, error) { diff --git a/api/initialise_test.go b/api/initialise_test.go index 0d4d392d9..4dbb90a3e 100644 --- a/api/initialise_test.go +++ b/api/initialise_test.go @@ -22,6 +22,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/stretchr/testify/mock" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" "google.golang.org/grpc/test/bufconn" gpb "github.com/openconfig/gnmi/proto/gnmi" @@ -48,7 +49,7 @@ var sbiUUID uuid.UUID func bootstrapUnitTest() { dialOptions = []grpc.DialOption{ grpc.WithContextDialer(bufDialer), - grpc.WithInsecure(), + grpc.WithTransportCredentials(insecure.NewCredentials()), } lis = bufconn.Listen(bufSize) s := grpc.NewServer() diff --git a/controller.go b/controller.go index 2cc38d435..ea7db97e3 100644 --- a/controller.go +++ b/controller.go @@ -13,6 +13,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/spf13/viper" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" pb "code.fbi.h-da.de/danet/api/go/gosdn/core" cpb "code.fbi.h-da.de/danet/api/go/gosdn/csbi" @@ -104,7 +105,7 @@ func startGrpc() error { }() orchestrator := viper.GetString("csbi-orchestrator") - conn, err := grpc.Dial(orchestrator, grpc.WithInsecure()) + conn, err := grpc.Dial(orchestrator, grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatal(err) } @@ -120,7 +121,6 @@ func createSouthboundInterfaces() (southbound.SouthboundInterface, error) { } return sbi, nil - } // createPrincipalNetworkDomain initializes the controller with an initial PND diff --git a/northbound/server/core.go b/northbound/server/core.go index 713cc92c5..b72fe1d01 100644 --- a/northbound/server/core.go +++ b/northbound/server/core.go @@ -77,7 +77,6 @@ func (s core) CreatePndList(ctx context.Context, request *pb.CreatePndListReques start := metrics.StartHook(labels, grpcRequestsTotal) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) for _, r := range request.Pnd { - sbi, err := nucleus.NewSBI(spb.Type_TYPE_OPENCONFIG) if err != nil { return nil, handleRPCError(labels, err) diff --git a/northbound/server/pnd.go b/northbound/server/pnd.go index 3cfdbd6fb..9d6f71ad8 100644 --- a/northbound/server/pnd.go +++ b/northbound/server/pnd.go @@ -189,7 +189,6 @@ func (p pndServer) GetSbiList(ctx context.Context, request *ppb.GetSbiListReques }, Sbi: sbis, }, nil - } func fillSbis(pnd networkdomain.NetworkDomain, all bool, sid ...string) ([]*spb.SouthboundInterface, error) { @@ -283,7 +282,6 @@ func (p pndServer) GetPath(ctx context.Context, request *ppb.GetPathRequest) (*p }, Device: ond[0].Device, }, nil - } func (p pndServer) GetChange(ctx context.Context, request *ppb.GetChangeRequest) (*ppb.GetChangeResponse, error) { @@ -505,7 +503,6 @@ func (p pndServer) SetPathList(ctx context.Context, request *ppb.SetPathListRequ }, }, }, nil - } func (p pndServer) SetSbiList(ctx context.Context, request *ppb.SetSbiListRequest) (*ppb.SetSbiListResponse, error) { @@ -588,5 +585,4 @@ func (p pndServer) DeleteOnd(ctx context.Context, request *ppb.DeleteOndRequest) Timestamp: time.Now().UnixNano(), Status: ppb.Status_STATUS_OK, }, nil - } diff --git a/northbound/server/pnd_test.go b/northbound/server/pnd_test.go index 0f8767850..b2e7595ab 100644 --- a/northbound/server/pnd_test.go +++ b/northbound/server/pnd_test.go @@ -21,6 +21,7 @@ import ( log "github.com/sirupsen/logrus" "github.com/stretchr/testify/mock" "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" cpb "code.fbi.h-da.de/danet/api/go/gosdn/csbi" ) @@ -55,7 +56,7 @@ func getMockPND() networkdomain.NetworkDomain { log.Fatal(err) } - conn, err := grpc.Dial("orchestrator", grpc.WithInsecure()) + conn, err := grpc.Dial("orchestrator", grpc.WithTransportCredentials(insecure.NewCredentials())) if err != nil { log.Fatal(err) } @@ -181,7 +182,7 @@ func Test_pnd_Get(t *testing.T) { tests := []struct { name string args args - want pb.GetPndResponse + want *pb.GetPndResponse wantErr bool }{ { @@ -193,7 +194,7 @@ func Test_pnd_Get(t *testing.T) { pndID}, }, }, - want: pb.GetPndResponse{ + want: &pb.GetPndResponse{ Pnd: []*ppb.PrincipalNetworkDomain{ {Id: pndID, Name: "test", diff --git a/nucleus/southbound.go b/nucleus/southbound.go index 5e7b1528f..4bf8e06ec 100644 --- a/nucleus/southbound.go +++ b/nucleus/southbound.go @@ -36,7 +36,6 @@ func NewSBI(southbound spb.Type, sbUUID ...uuid.UUID) (southbound.SouthboundInte return &OpenConfig{id: id}, nil default: return nil, errors.ErrTypeNotSupported{Type: southbound} - } } -- GitLab