Skip to content
Snippets Groups Projects
Commit b06e6cbf authored by Fabian Seidl's avatar Fabian Seidl Committed by Neil-Jocelyn Schark
Browse files

Resolve "Credentials returned after registering an app are hard coded, which...

Resolve "Credentials returned after registering an app are hard coded, which causes problems if RabbitMQ is not hosted on localhost"

See merge request danet/gosdn!755
parent 376a6c7a
No related branches found
No related tags found
1 merge request!755Resolve "Credentials returned after registering an app are hard coded, which causes problems if RabbitMQ is not hosted on localhost"
Pipeline #184708 failed
...@@ -4,6 +4,7 @@ import ( ...@@ -4,6 +4,7 @@ import (
"context" "context"
"fmt" "fmt"
"code.fbi.h-da.de/danet/gosdn/controller/config"
"code.fbi.h-da.de/danet/gosdn/controller/store" "code.fbi.h-da.de/danet/gosdn/controller/store"
"github.com/google/uuid" "github.com/google/uuid"
) )
...@@ -66,7 +67,7 @@ func (a *Service) createNewApp(appName string) (*App, error) { ...@@ -66,7 +67,7 @@ func (a *Service) createNewApp(appName string) (*App, error) {
app := App{ app := App{
ID: uuid.New(), ID: uuid.New(),
Name: appName, Name: appName,
EventSystemCredentials: "amqp://guest:guest@127.0.0.1:5672", EventSystemCredentials: buildQueueCredentials(),
} }
// generate app credentials // generate app credentials
...@@ -77,3 +78,7 @@ func (a *Service) createNewApp(appName string) (*App, error) { ...@@ -77,3 +78,7 @@ func (a *Service) createNewApp(appName string) (*App, error) {
return &app, nil return &app, nil
} }
func buildQueueCredentials() string {
return fmt.Sprintf("%s%s:%s@%s:%s/", config.AMQPPrefix, config.AMQPUser, config.AMQPPassword, config.AMQPHost, config.AMQPPort)
}
...@@ -14,6 +14,7 @@ import ( ...@@ -14,6 +14,7 @@ import (
) )
const localhost = "127.0.0.1" const localhost = "127.0.0.1"
const rabbitmq = "rabbitmq"
// Application is an example for a sdn application. // Application is an example for a sdn application.
type Application struct { type Application struct {
...@@ -33,8 +34,8 @@ func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, contro ...@@ -33,8 +34,8 @@ func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, contro
os.Exit(1) os.Exit(1)
} }
if rabbitMQAddress != "" { if rabbitMQAddress == "" {
queueCredentials = strings.ReplaceAll(queueCredentials, localhost, rabbitMQAddress) queueCredentials = strings.ReplaceAll(queueCredentials, rabbitmq, localhost)
} }
eventService, err := event.NewEventService( eventService, err := event.NewEventService(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment