35 lines
870 B
Go
35 lines
870 B
Go
package initialize
|
|
|
|
import (
|
|
"gitea.pena/PenaSide/common/mongo"
|
|
"github.com/caarlos0/env/v8"
|
|
"github.com/joho/godotenv"
|
|
"log"
|
|
)
|
|
|
|
type Config struct {
|
|
KafkaBrokers string `env:"KAFKA_BROKERS"`
|
|
KafkaTopic string `env:"KAFKA_TOPIC_TARIFF"`
|
|
SmtpApiUrl string `env:"SMTP_API_URL"`
|
|
SmtpHost string `env:"SMTP_HOST"`
|
|
SmtpPort string `env:"SMTP_PORT"`
|
|
SmtpUsername string `env:"SMTP_UNAME"`
|
|
SmtpPassword string `env:"SMTP_PASS"`
|
|
SmtpApiKey string `env:"SMTP_API_KEY"`
|
|
SmtpSender string `env:"SMTP_SENDER"`
|
|
CustomerURL string `env:"CUSTOMER_URL"`
|
|
QuizRPCURL string `enc:"QUIZ_RPC_URL"`
|
|
DataBase mongo.Configuration
|
|
}
|
|
|
|
func LoadConfig() (*Config, error) {
|
|
if err := godotenv.Load(); err != nil {
|
|
log.Print("No .env file found")
|
|
}
|
|
var config Config
|
|
if err := env.Parse(&config); err != nil {
|
|
return nil, err
|
|
}
|
|
return &config, nil
|
|
}
|