Skip to content

Commit

Permalink
initialize auth url
Browse files Browse the repository at this point in the history
Signed-off-by: mteodor <mirko.teodorovic@gmail.com>
  • Loading branch information
mteodor committed Dec 13, 2021
1 parent 8741b32 commit b13ae3c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 6 deletions.
11 changes: 10 additions & 1 deletion cmd/cassandra-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ const (
defServerCert = ""
defServerKey = ""
defJaegerURL = ""
defThingsAuthURL = "localhost:8181"
defThingsAuthURL = "localhost:8183"
defThingsAuthTimeout = "1s"
defUsersAuthURL = "localhost:8181"
defUsersAuthTimeout = "1s"

envLogLevel = "MF_CASSANDRA_READER_LOG_LEVEL"
Expand All @@ -65,6 +66,7 @@ const (
envJaegerURL = "MF_JAEGER_URL"
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
envUsersAuthURL = "MF_AUTH_GRPC_URL"
envUsersAuthTimeout = "MF_AUTH_GRPC_TIMEOUT"
)

Expand Down Expand Up @@ -175,6 +177,11 @@ func loadConfig() config {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

usersAuthTimeout, err := time.ParseDuration(mainflux.Env(envUsersAuthTimeout, defUsersAuthTimeout))
if err != nil {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

return config{
logLevel: mainflux.Env(envLogLevel, defLogLevel),
port: mainflux.Env(envPort, defPort),
Expand All @@ -185,6 +192,8 @@ func loadConfig() config {
serverKey: mainflux.Env(envServerKey, defServerKey),
jaegerURL: mainflux.Env(envJaegerURL, defJaegerURL),
thingsAuthURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL),
usersAuthURL: mainflux.Env(envUsersAuthURL, defUsersAuthURL),
usersAuthTimeout: usersAuthTimeout,
thingsAuthTimeout: authTimeout,
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/influxdb-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ const (
defServerKey = ""
defJaegerURL = ""
defThingsAuthURL = "localhost:8183"
defUsersAuthURL = "localhost:8181"
defThingsAuthTimeout = "1s"
defUsersAuthURL = "localhost:8181"
defUsersAuthTimeout = "1s"

envLogLevel = "MF_INFLUX_READER_LOG_LEVEL"
Expand Down
13 changes: 11 additions & 2 deletions cmd/mongodb-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ const (
defServerCert = ""
defServerKey = ""
defJaegerURL = ""
defThingsAuthURL = "localhost:8181"
defUsersAuthURL = "localhost:8181"
defThingsAuthURL = "localhost:8183"
defThingsAuthTimeout = "1s"
defUsersAuthURL = "localhost:8181"
defUsersAuthTimeout = "1s"

envLogLevel = "MF_MONGO_READER_LOG_LEVEL"
Expand All @@ -61,6 +61,8 @@ const (
envJaegerURL = "MF_JAEGER_URL"
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
envUsersAuthURL = "MF_AUTH_GRPC_URL"
envUsersAuthTimeout = "MF_AUTH_GRPC_TIMEOUT"
)

type config struct {
Expand Down Expand Up @@ -157,6 +159,11 @@ func loadConfigs() config {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

usersAuthTimeout, err := time.ParseDuration(mainflux.Env(envUsersAuthTimeout, defUsersAuthTimeout))
if err != nil {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

return config{
logLevel: mainflux.Env(envLogLevel, defLogLevel),
port: mainflux.Env(envPort, defPort),
Expand All @@ -169,7 +176,9 @@ func loadConfigs() config {
serverKey: mainflux.Env(envServerKey, defServerKey),
jaegerURL: mainflux.Env(envJaegerURL, defJaegerURL),
thingsAuthURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL),
usersAuthURL: mainflux.Env(envUsersAuthURL, defUsersAuthURL),
thingsAuthTimeout: authTimeout,
usersAuthTimeout: usersAuthTimeout,
}
}

Expand Down
12 changes: 10 additions & 2 deletions cmd/postgres-reader/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ const (
defDBSSLKey = ""
defDBSSLRootCert = ""
defJaegerURL = ""
defThingsAuthURL = "localhost:8181"
defThingsAuthURL = "localhost:8183"
defThingsAuthTimeout = "1s"
defUsersAuthURL = "localhost:8181"
defUsersAuthTimeout = "1s"

envLogLevel = "MF_POSTGRES_READER_LOG_LEVEL"
Expand All @@ -69,7 +70,7 @@ const (
envJaegerURL = "MF_JAEGER_URL"
envThingsAuthURL = "MF_THINGS_AUTH_GRPC_URL"
envThingsAuthTimeout = "MF_THINGS_AUTH_GRPC_TIMEOUT"
envAuthURL = "MF_AUTH_GRPC_URL"
envUsersAuthURL = "MF_AUTH_GRPC_URL"
envUsersAuthTimeout = "MF_AUTH_GRPC_TIMEOUT"
)

Expand Down Expand Up @@ -178,6 +179,11 @@ func loadConfig() config {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

usersAuthTimeout, err := time.ParseDuration(mainflux.Env(envUsersAuthTimeout, defUsersAuthTimeout))
if err != nil {
log.Fatalf("Invalid %s value: %s", envThingsAuthTimeout, err.Error())
}

return config{
logLevel: mainflux.Env(envLogLevel, defLogLevel),
port: mainflux.Env(envPort, defPort),
Expand All @@ -186,7 +192,9 @@ func loadConfig() config {
dbConfig: dbConfig,
jaegerURL: mainflux.Env(envJaegerURL, defJaegerURL),
thingsAuthURL: mainflux.Env(envThingsAuthURL, defThingsAuthURL),
usersAuthURL: mainflux.Env(envUsersAuthURL, defUsersAuthURL),
thingsAuthTimeout: authTimeout,
usersAuthTimeout: usersAuthTimeout,
}
}

Expand Down

0 comments on commit b13ae3c

Please sign in to comment.