Skip to content
Snippets Groups Projects
Commit 93f48c81 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

Resolve "Running the controller via VSCode uses different paths for...

Resolve "Running the controller via VSCode uses different paths for configs/stores/etc. which leads to some problems"

See merge request !360
parent 5f445a11
No related branches found
No related tags found
2 merge requests!360Resolve "Running the controller via VSCode uses different paths for configs/stores/etc. which leads to some problems",!333WIP: Develop
Pipeline #110750 passed
This commit is part of merge request !333. Comments created here will be created in the context of that merge request.
......@@ -21,6 +21,7 @@ const (
jwtDurationKey = "defaultJWTDuration"
defaultJWTDuration = time.Hour * 24
jwtSecretKey = "jwtSecret"
gNMISubscriptionsFilePathKey = "gNMISubscriptionsPath"
// RabbitMQ Broker
amqpPrefixKey = "amqpPrefix"
......@@ -72,6 +73,9 @@ var AMQPHost string
// AMQPPort is the amqp port
var AMQPPort string
// GNMISubscriptionsFilePath is the path to the file used for automated subscriptions
var GNMISubscriptionsFilePath string
// Init gets called on module import
func Init() {
err := InitializeConfig()
......@@ -125,6 +129,8 @@ func InitializeConfig() error {
JWTSecret = viper.GetString(jwtSecretKey)
GNMISubscriptionsFilePath = getStringFromViper(gNMISubscriptionsFilePathKey)
loadAMQPConfig()
if err := viper.WriteConfig(); err != nil {
......
......@@ -16,12 +16,18 @@ var gnmiSubscriptionPaths [][]string
// ReadGnmiSubscriptionPaths reads the paths the watcher should subscribe to provided in a file.
func ReadGnmiSubscriptionPaths() error {
currentDir, err := os.Getwd()
if err != nil {
return err
}
var filePath string
filePath := filepath.Join(currentDir, defaultGnmiSubscriptionFilePath)
if GNMISubscriptionsFilePath != "" {
filePath = GNMISubscriptionsFilePath
} else {
currentDir, err := os.Getwd()
if err != nil {
return err
}
filePath = filepath.Join(currentDir, defaultGnmiSubscriptionFilePath)
}
f, err := os.Open(filePath)
if err != nil {
......
......@@ -11,6 +11,8 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
socket = ":55055"
databaseConnection = "mongodb://root:example@clab-gosdn_csbi_arista_base-mongodb:27017"
filesystemPathToStores = "stores"
gNMISubscriptionsPath = "controller/configs/gNMISubscriptions.txt"
amqpPrefix = "amqp://"
amqpUser = "guest"
......
......@@ -11,7 +11,7 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
socket = ":55055"
databaseConnection = "mongodb://root:example@localhost:27017"
filesystemPathToStores = "stores"
gNMISubscriptionsPath = "controller/configs/gNMISubscriptions.txt"
amqpPrefix = "amqp://"
amqpUser = "guest"
......
......@@ -112,8 +112,6 @@ func initialize() error {
}
c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore)
// TODO: udpate with actual paths to subscribe when using template/config
fmt.Println(config.GetGnmiSubscriptionPaths())
c.deviceWatcher.SubToDevices(config.GetGnmiSubscriptionPaths(), nil)
err = ensureDefaultRoleExists()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment