diff --git a/.gitignore b/.gitignore index 83d7fcf53ce03d7dcb7af95d784535e225453b15..2dcac5e10f703e04f4b9194574241f179273f837 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ test/.terraform.local/ configs/gosdn.toml api/api_test.toml debug.test + +# Binary +gosdn diff --git a/api/api_test.go b/api/api_test.go index a55113c1a25364a28e251e9fd200cecf408dafce..a3f722da0509f09585d713520a0274ec5a39c5ce 100644 --- a/api/api_test.go +++ b/api/api_test.go @@ -72,7 +72,6 @@ func Test_CommitConfirm(t *testing.T) { return } log.Info(resp) - } func Test_AddDevice(t *testing.T) { diff --git a/api/initialise_test.go b/api/initialise_test.go index 7a7429a96db3b2997f70b4ef3e4bddcfcb336ea9..c6a00cc2770e63cea87b577fe61c223e292a9c05 100644 --- a/api/initialise_test.go +++ b/api/initialise_test.go @@ -112,7 +112,6 @@ func bufDialer(context.Context, string) (net.Conn, error) { return lis.Dial() } -const unreachable = "203.0.113.10:6030" const testPath = "/system/config/hostname" var testAddress = "141.100.70.170:6030" diff --git a/build/ci/.code-quality-ci.yml b/build/ci/.code-quality-ci.yml index a608dd15e896e417aa25e19ee8657c037aa3e75e..3e5c205d954965a11da9e0961b1fc6aad8639c14 100644 --- a/build/ci/.code-quality-ci.yml +++ b/build/ci/.code-quality-ci.yml @@ -1,5 +1,5 @@ code-quality: - image: golangci/golangci-lint:latest-alpine + image: golangci/golangci-lint:v1.42-alpine stage: test rules: - if: $CI_PIPELINE_SOURCE == "merge_request_event" diff --git a/build/ci/.golangci-config/.golangci.yml b/build/ci/.golangci-config/.golangci.yml index 1a2b9183717c0c1a95b8782e15a5189ee2059c10..e9ea64defdbb908d5d1892ff7f8351aaa6cc7a6a 100644 --- a/build/ci/.golangci-config/.golangci.yml +++ b/build/ci/.golangci-config/.golangci.yml @@ -27,9 +27,13 @@ linters: enable: - gofmt - goimports - - revive - gocyclo - govet + - unused + - staticcheck + - typecheck + - revive + - whitespace issues: exclude-use-default: false max-issues-per-linter: 0 diff --git a/controller.go b/controller.go index ed28c31be19a7864f52f63cd00188be24e98c819..d668c1753618fe44276c3b9d6885ccb623e29bdb 100644 --- a/controller.go +++ b/controller.go @@ -90,6 +90,9 @@ func startGrpc() error { orchestrator := viper.GetString("csbi-orchestrator") conn, err := grpc.Dial(orchestrator, grpc.WithInsecure()) + if err != nil { + log.Fatal(err) + } c.csbiClient = cpb.NewCsbiClient(conn) return nil } diff --git a/http_test.go b/http_test.go index 7b4926e16be0ee4548124b825d02e1cb8fcdcc99..94092e1ca63a862359cd9ca9ba4ad2fa753b4721 100644 --- a/http_test.go +++ b/http_test.go @@ -6,7 +6,6 @@ import ( ) func Test_httpApi(t *testing.T) { - tests := []struct { name string request string diff --git a/northbound/server/pnd.go b/northbound/server/pnd.go index 3e06a57809cf9f0306d8b54372fb665d1aae4db3..a25aefc09c97da1d7f0737467abea6412f114ad6 100644 --- a/northbound/server/pnd.go +++ b/northbound/server/pnd.go @@ -349,13 +349,6 @@ func handleSetOnd(pnd networkdomain.NetworkDomain, req []*ppb.SetOnd) (*ppb.SetR }, nil } -func handleSetSbi(pnd networkdomain.NetworkDomain, req []*ppb.SetSbi) (*ppb.SetResponse, error) { - return &ppb.SetResponse{ - Timestamp: time.Now().UnixNano(), - Status: ppb.SetResponse_ERROR, - }, nil -} - func handleSetChange(pnd networkdomain.NetworkDomain, req []*ppb.SetChange) (*ppb.SetResponse, error) { for _, r := range req { cuid, err := uuid.Parse(r.Cuid) diff --git a/nucleus/change.go b/nucleus/change.go index f64a99eaba5de7fa43ddcb52ff5adb6d14282a37..5340cfca151c77830830df0d336dd05f6d334681 100644 --- a/nucleus/change.go +++ b/nucleus/change.go @@ -132,7 +132,6 @@ func stateManager(ch *Change, timeout time.Duration) (chan<- ppb.Change_State, < errChan <- err } errChan <- fmt.Errorf("change %v timed out", ch.cuid) - break case s := <-stateIn: switch s { case ppb.Change_COMMITTED: diff --git a/nucleus/gnmi_transport.go b/nucleus/gnmi_transport.go index fb5b3016d64418e789dfb56125a40f8b77173725..e98faa28da5f0e676bbc2bd097226a4687b2d3e4 100644 --- a/nucleus/gnmi_transport.go +++ b/nucleus/gnmi_transport.go @@ -9,8 +9,6 @@ import ( "code.fbi.h-da.de/danet/gosdn/interfaces/southbound" - "google.golang.org/grpc" - ppb "code.fbi.h-da.de/danet/api/go/gosdn/pnd" "code.fbi.h-da.de/danet/forks/goarista/gnmi" @@ -71,10 +69,6 @@ func newGnmiTransport(opts *tpb.TransportOption, sbi southbound.SouthboundInterf }, nil } -func parseDialOptions(opts map[string]string) []grpc.DialOption { - return nil -} - // Get takes a slice of gnmi paths, splits them and calls get for each one of them. func (g *Gnmi) Get(ctx context.Context, params ...string) (interface{}, error) { if g.client == nil { diff --git a/nucleus/principalNetworkDomain.go b/nucleus/principalNetworkDomain.go index b0238a095dfb2766e9712b7974614229f560a314..f64e7c0dae2960521f59521ed103cfbe20767c07 100644 --- a/nucleus/principalNetworkDomain.go +++ b/nucleus/principalNetworkDomain.go @@ -320,6 +320,7 @@ func (pnd *pndImplementation) ChangeOND(duid uuid.UUID, operation ppb.ApiOperati return ch.cuid, nil } +// nolint will be implemented in the near future func handleRollbackError(id uuid.UUID, err error) { log.Error(err) // TODO: Notion of invalid state needed. diff --git a/nucleus/principalNetworkDomain_test.go b/nucleus/principalNetworkDomain_test.go index d14fd7f76b3a18f26e0d6134401ac47512768b6d..3a9c23f25cbda982f79ef90af8df3bbe76100b66 100644 --- a/nucleus/principalNetworkDomain_test.go +++ b/nucleus/principalNetworkDomain_test.go @@ -693,7 +693,6 @@ func Test_pndImplementation_GetDevice(t *testing.T) { t.Errorf("GetDevice() got = %v, want %v", foundDevice.(device.Device).Model(), tt.want) } } - }) } } @@ -744,7 +743,6 @@ func Test_pndImplementation_GetDeviceByName(t *testing.T) { t.Errorf("GetDeviceByName() got = %v, want %v", foundDevice.(device.Device).Model(), tt.want) } } - }) } } diff --git a/nucleus/southbound_test.go b/nucleus/southbound_test.go index 2f92d24a1d00d1663d0f86622a08c4773b366ebd..1994cf71d0335501025b28ba0d9eb2fc85458485 100644 --- a/nucleus/southbound_test.go +++ b/nucleus/southbound_test.go @@ -6,8 +6,6 @@ import ( spb "code.fbi.h-da.de/danet/api/go/gosdn/southbound" - "code.fbi.h-da.de/danet/gosdn/interfaces/transport" - "code.fbi.h-da.de/danet/gosdn/nucleus/util/path" "code.fbi.h-da.de/danet/gosdn/nucleus/util/proto" "code.fbi.h-da.de/danet/yang-models/generated/openconfig" @@ -19,9 +17,8 @@ import ( func TestOpenConfig_Id(t *testing.T) { type fields struct { - transport transport.Transport - schema *ytypes.Schema - id uuid.UUID + schema *ytypes.Schema + id uuid.UUID } tests := []struct { name string diff --git a/nucleus/transport.go b/nucleus/transport.go index abeeeca7476f63bdec1320877f0c2321ce010e24..49d74e1c2d3795a9b2a987625b756be7b4939ef6 100644 --- a/nucleus/transport.go +++ b/nucleus/transport.go @@ -29,7 +29,6 @@ func NewTransport(opts *tpb.TransportOption, sbi southbound.SouthboundInterface) return newGnmiTransport(opts, sbi) default: return nil, &errors.ErrInvalidTransportOptions{Opt: o} - } } diff --git a/nucleus/util/path/traverse.go b/nucleus/util/path/traverse.go index c246ebddff0d5fe9396faa22ff9cb6ca5b923e09..403ffc5e441f86013e3eb35a7b6ab331e50b0fb9 100644 --- a/nucleus/util/path/traverse.go +++ b/nucleus/util/path/traverse.go @@ -71,7 +71,6 @@ func processEntry(e *yang.Entry) *Element { // Strings constructs a slice containg all possible root to leaf paths. // Calls stringBuilder internally func Strings(paths map[string]*Element) []string { - p := make([]string, 0) ch := make(chan string) stop := make(chan bool) val := make(chan []string) @@ -81,7 +80,8 @@ func Strings(paths map[string]*Element) []string { stringBuilder(ch, &b, v) } stop <- true - p = <-val + p := <-val + return p } @@ -95,7 +95,6 @@ func appendix(c chan string, stop chan bool, pathChan chan []string) { log.Debug(path) case sig = <-stop: log.Debugf("Signal received: %v", sig) - } if sig { break