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

Fix: Govulncheck reports errors for csbi

The csbi implementation is currently not supported and therefore the
`Discover` function has been changed to return a `not implemented` error.
parent c916b109
No related branches found
No related tags found
1 merge request!401Change the current gosdn plugin implementation from Go's internal plugin system to hashicorp's go-plugins
......@@ -2,40 +2,38 @@ package csbi
import (
"context"
"reflect"
"fmt"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
tpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/transport"
"code.fbi.h-da.de/danet/gosdn/controller/customerrs"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus"
"github.com/openconfig/gnmi/proto/gnmi"
)
// Discover sends a gnmi Capabilities request to the specified target and
// returns the gnmi.ModelData.
func Discover(ctx context.Context, opts *tpb.TransportOption) ([]*gnmi.ModelData, error) {
sbi, err := nucleus.NewSBI(spb.Type_TYPE_OPENCONFIG)
if err != nil {
return nil, err
}
t, err := nucleus.NewTransport(opts, sbi)
if err != nil {
return nil, err
}
transport, ok := t.(*nucleus.Gnmi)
if !ok {
return nil, &customerrs.InvalidTypeAssertionError{}
}
resp, err := transport.Capabilities(ctx)
if err != nil {
return nil, err
}
capabilities, ok := resp.(*gnmi.CapabilityResponse)
if !ok {
return nil, &customerrs.InvalidTypeAssertionError{
Value: resp,
Type: reflect.TypeOf(&gnmi.CapabilityResponse{}),
}
}
return capabilities.SupportedModels, nil
//sbi, err := nucleus.NewSBI(spb.Type_TYPE_OPENCONFIG)
//if err != nil {
// return nil, err
//}
//t, err := nucleus.NewTransport(opts, sbi)
//if err != nil {
// return nil, err
//}
//transport, ok := t.(*nucleus.Gnmi)
//if !ok {
// return nil, &customerrs.InvalidTypeAssertionError{}
//}
//resp, err := transport.Capabilities(ctx)
//if err != nil {
// return nil, err
//}
//capabilities, ok := resp.(*gnmi.CapabilityResponse)
//if !ok {
// return nil, &customerrs.InvalidTypeAssertionError{
// Value: resp,
// Type: reflect.TypeOf(&gnmi.CapabilityResponse{}),
// }
//}
//return capabilities.SupportedModels, nil
return nil, fmt.Errorf("currently not implemented")
}
......@@ -10,7 +10,6 @@ import (
"time"
pb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/util"
"github.com/google/uuid"
"github.com/prometheus/client_golang/prometheus"
log "github.com/sirupsen/logrus"
......@@ -114,17 +113,17 @@ func (s server) GetFile(req *pb.GetPayloadRequest, stream pb.CsbiService_GetFile
}()
switch fn := req.GetFile(); {
case fn == util.GoStructName:
case fn == gostructName:
file, err = os.Open(filepath.Join(req.GetDid(), gostructName))
if err != nil {
return handleRPCError(labels, err)
}
case fn == util.ManifestFileName:
case fn == manifestFileName:
file, err = os.Open(filepath.Join(req.GetDid(), manifestFileName))
if err != nil {
return handleRPCError(labels, err)
}
case fn == util.GoStructAdditionsName:
case fn == gostructAdditionsName:
file, err = os.Open(filepath.Join(req.GetDid(), gostructAdditionsName))
if err != nil {
return handleRPCError(labels, err)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment