Skip to content
Snippets Groups Projects
Commit 0a290d1e authored by André Sterba's avatar André Sterba
Browse files

Remove dead code

parent 621525c9
Branches
Tags
1 merge request!312Enable deadcode linter
Pipeline #101106 failed
...@@ -27,7 +27,6 @@ import ( ...@@ -27,7 +27,6 @@ import (
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/northbound/server" "code.fbi.h-da.de/danet/gosdn/controller/northbound/server"
nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/server"
rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac" rbacImpl "code.fbi.h-da.de/danet/gosdn/controller/rbac"
...@@ -138,16 +137,6 @@ func startGrpc() error { ...@@ -138,16 +137,6 @@ func startGrpc() error {
return nil return nil
} }
// createSouthboundInterfaces initializes the controller with its supported SBIs
func createSouthboundInterfaces() (southbound.SouthboundInterface, error) {
sbi, err := nucleus.NewSBI(spb.Type(config.BaseSouthBoundType), config.BaseSouthBoundUUID)
if err != nil {
return nil, err
}
return sbi, nil
}
// createPrincipalNetworkDomain initializes the controller with an initial PND // createPrincipalNetworkDomain initializes the controller with an initial PND
func createPrincipalNetworkDomain() error { func createPrincipalNetworkDomain() error {
basePnd, err := c.pndStore.Get(store.Query{ID: config.BasePndUUID}) basePnd, err := c.pndStore.Get(store.Query{ID: config.BasePndUUID})
......
...@@ -11,7 +11,6 @@ import ( ...@@ -11,7 +11,6 @@ import (
ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd" ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound" spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/device" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/device"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkdomain"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/mocks" "code.fbi.h-da.de/danet/gosdn/controller/mocks"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus" "code.fbi.h-da.de/danet/gosdn/controller/nucleus"
...@@ -24,10 +23,6 @@ import ( ...@@ -24,10 +23,6 @@ import (
"github.com/openconfig/gnmi/proto/gnmi" "github.com/openconfig/gnmi/proto/gnmi"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
cpb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/csbi"
) )
const pndID = "2043519e-46d1-4963-9a8e-d99007e104b8" const pndID = "2043519e-46d1-4963-9a8e-d99007e104b8"
...@@ -45,32 +40,8 @@ var committedChangeUUID uuid.UUID ...@@ -45,32 +40,8 @@ var committedChangeUUID uuid.UUID
var deviceUUID uuid.UUID var deviceUUID uuid.UUID
var mockPnd *mocks.NetworkDomain var mockPnd *mocks.NetworkDomain
var mockDevice device.Device var mockDevice device.Device
var mockJwt *rbac.JWTManager
var sbiStore southbound.Store var sbiStore southbound.Store
func callback(id uuid.UUID, ch chan device.Details) {
// Need for pnd creation, but not needed for this test case.
}
func getMockPND() networkdomain.NetworkDomain {
conn, err := grpc.Dial("orchestrator", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
csbiClient := cpb.NewCsbiServiceClient(conn)
newPnd, _ := nucleus.NewPND(
"test",
"test",
pndUUID,
csbiClient,
callback,
)
return newPnd
}
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
log.SetReportCaller(true) log.SetReportCaller(true)
var err error var err error
......
package nucleus package nucleus
import ( import (
spb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/database" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/database"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors"
...@@ -107,9 +106,3 @@ func (s *DatabaseSbiStore) GetAll() ([]southbound.LoadedSbi, error) { ...@@ -107,9 +106,3 @@ func (s *DatabaseSbiStore) GetAll() ([]southbound.LoadedSbi, error) {
return loadedSbis, nil return loadedSbis, nil
} }
func getSbiTypeFromString(sbiTypeAsString string) spb.Type {
sbiTypeInt := spb.Type_value[sbiTypeAsString]
return spb.Type(sbiTypeInt)
}
package store package store
import ( import (
"os"
"path/filepath"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors" "code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors"
"github.com/google/uuid" "github.com/google/uuid"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
const (
pathToStores string = "stores"
)
// FromString is a helper to check if a provided string as a valid UUID or a name. // FromString is a helper to check if a provided string as a valid UUID or a name.
func FromString(id string) (uuid.UUID, error) { func FromString(id string) (uuid.UUID, error) {
idAsUUID, err := uuid.Parse(id) idAsUUID, err := uuid.Parse(id)
...@@ -28,46 +21,3 @@ func FromString(id string) (uuid.UUID, error) { ...@@ -28,46 +21,3 @@ func FromString(id string) (uuid.UUID, error) {
return idAsUUID, nil return idAsUUID, nil
} }
func ensureFilesystemStorePathExists(storeFileName string) error {
completeStorePath := filepath.Join(pathToStores, storeFileName)
if _, err := os.Stat(completeStorePath); os.IsNotExist(err) {
err := ensureFileSystemStoreExists(completeStorePath)
if err != nil {
return err
}
}
return nil
}
func ensureFileSystemStoreExists(pathToStore string) error {
err := ensureDirExists(pathToStore)
if err != nil {
return err
}
emptyArray := []byte("[]")
err = os.WriteFile(pathToStore, emptyArray, 0600)
if err != nil {
return err
}
return nil
}
func ensureDirExists(fileName string) error {
dirName := filepath.Dir(fileName)
if _, serr := os.Stat(dirName); serr != nil {
merr := os.MkdirAll(dirName, os.ModePerm)
if merr != nil {
return merr
}
}
return nil
}
func getCompletePathToFileStore(storeName string) string {
return filepath.Join(pathToStores, storeName)
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment