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

Remove dead code

parent 53c203a5
No related branches found
No related tags found
1 merge request!312Enable deadcode linter
Pipeline #101113 passed
......@@ -27,7 +27,6 @@ import (
"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/rbac"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/southbound"
"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"
......@@ -138,16 +137,6 @@ func startGrpc() error {
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
func createPrincipalNetworkDomain() error {
basePnd, err := c.pndStore.Get(store.Query{ID: config.BasePndUUID})
......
......@@ -11,7 +11,6 @@ import (
ppb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/pnd"
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/networkdomain"
"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/nucleus"
......@@ -24,10 +23,6 @@ import (
"github.com/openconfig/gnmi/proto/gnmi"
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/gosdn/api/go/gosdn/csbi"
)
const pndID = "2043519e-46d1-4963-9a8e-d99007e104b8"
......@@ -45,32 +40,8 @@ var committedChangeUUID uuid.UUID
var deviceUUID uuid.UUID
var mockPnd *mocks.NetworkDomain
var mockDevice device.Device
var mockJwt *rbac.JWTManager
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) {
log.SetReportCaller(true)
var err error
......
package nucleus
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/nucleus/database"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors"
......@@ -107,9 +106,3 @@ func (s *DatabaseSbiStore) GetAll() ([]southbound.LoadedSbi, error) {
return loadedSbis, nil
}
func getSbiTypeFromString(sbiTypeAsString string) spb.Type {
sbiTypeInt := spb.Type_value[sbiTypeAsString]
return spb.Type(sbiTypeInt)
}
package store
import (
"os"
"path/filepath"
"code.fbi.h-da.de/danet/gosdn/controller/nucleus/errors"
"github.com/google/uuid"
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.
func FromString(id string) (uuid.UUID, error) {
idAsUUID, err := uuid.Parse(id)
......@@ -28,46 +21,3 @@ func FromString(id string) (uuid.UUID, error) {
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