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

Linter pleasing

parent f54028e1
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
Pipeline #135497 failed
...@@ -2,11 +2,9 @@ package nucleus ...@@ -2,11 +2,9 @@ package nucleus
import ( import (
"context" "context"
"io/fs"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
"time"
eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService" eventservice "code.fbi.h-da.de/danet/gosdn/controller/eventService"
"code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement" "code.fbi.h-da.de/danet/gosdn/controller/interfaces/networkelement"
...@@ -188,7 +186,6 @@ func newPnd() (*pndImplementation, error) { ...@@ -188,7 +186,6 @@ func newPnd() (*pndImplementation, error) {
err := pluginService.Add(mockPlugin) err := pluginService.Add(mockPlugin)
if err != nil { if err != nil {
return nil, err return nil, err
} }
deviceService := NewNetworkElementService( deviceService := NewNetworkElementService(
deviceStore, deviceStore,
...@@ -208,42 +205,42 @@ func newPnd() (*pndImplementation, error) { ...@@ -208,42 +205,42 @@ func newPnd() (*pndImplementation, error) {
// removeTestGoStructs removes the plugins created during running the test in the current directory based on their name consisting of a uuid // removeTestGoStructs removes the plugins created during running the test in the current directory based on their name consisting of a uuid
// and the time since they`ve been created. // and the time since they`ve been created.
func removeTestGoStructs() { //func removeTestGoStructs() {
currentDirectory := "./" // currentDirectory := "./"
// pattern to match plugin uuid used as dir name // // pattern to match plugin uuid used as dir name
pattern := "*-*-*-*-*" // pattern := "*-*-*-*-*"
// max time passed since creation in seconds // // max time passed since creation in seconds
var seconds int64 = 10 // var seconds int64 = 10
//
// get all available files // // get all available files
dirs, err := os.ReadDir(currentDirectory) // dirs, err := os.ReadDir(currentDirectory)
if err != nil { // if err != nil {
log.Info(err) // log.Info(err)
} // }
//
for _, dir := range dirs { // for _, dir := range dirs {
if !dir.IsDir() { // if !dir.IsDir() {
continue // continue
} else if found, _ := filepath.Match(pattern, dir.Name()); found && isDirYoungerThanSeconds(dir.Name(), seconds) { // } else if found, _ := filepath.Match(pattern, dir.Name()); found && isDirYoungerThanSeconds(dir.Name(), seconds) {
log.Infof("removing: %v", dir.Name()) // log.Infof("removing: %v", dir.Name())
err = os.RemoveAll(dir.Name()) // err = os.RemoveAll(dir.Name())
if err != nil { // if err != nil {
log.Info(err) // log.Info(err)
} // }
} // }
} // }
} //}
// isDirYoungerThanSeconds returns true if the provided dir is younger than the given amount in seconds // isDirYoungerThanSeconds returns true if the provided dir is younger than the given amount in seconds
// and therefore was created as part of the test suite. // and therefore was created as part of the test suite.
func isDirYoungerThanSeconds(dirName string, seconds int64) bool { //func isDirYoungerThanSeconds(dirName string, seconds int64) bool {
fileInfo, err := os.Stat(dirName) // fileInfo, err := os.Stat(dirName)
if err != nil { // if err != nil {
log.Info(err) // log.Info(err)
} // }
//
return fs.FileInfo.ModTime(fileInfo).Unix() > (time.Now().Unix() - seconds) // return fs.FileInfo.ModTime(fileInfo).Unix() > (time.Now().Unix() - seconds)
} //}
func ensureStoreFileForTestsIsRemoved(storeName string) { func ensureStoreFileForTestsIsRemoved(storeName string) {
if err := store.EnsureFilesystemStorePathExists(storeName); err != nil { if err := store.EnsureFilesystemStorePathExists(storeName); err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment