feat: add check if envs are set

This commit is contained in:
Marco98
2026-03-27 20:30:14 +01:00
parent d9de8fa7a4
commit 3076c431e1

View File

@@ -43,10 +43,18 @@ func main() {
func run() error {
slog.Info("starting mcbdd", "version", version, "commit", commit, "date", date)
mailcowBase := os.Getenv("MAILCOW_BASE")
if mailcowBase == "" {
return fmt.Errorf("MAILCOW_BASE environment variable is not set")
}
mailcowAPIKey := os.Getenv("MAILCOW_APIKEY")
if mailcowAPIKey == "" {
return fmt.Errorf("MAILCOW_APIKEY environment variable is not set")
}
d := &Daemon{
userTokens: make(map[string]string),
userTokensLock: &sync.RWMutex{},
baseURL: os.Getenv("MAILCOW_BASE"),
baseURL: mailcowBase,
stateFilepath: os.Getenv("STATEFILE"),
httpClient: &http.Client{
Transport: &http.Transport{
@@ -59,8 +67,8 @@ func run() error {
}
d.mailcowClient = mailcow.New(
d.httpClient,
d.baseURL,
os.Getenv("MAILCOW_APIKEY"),
mailcowBase,
mailcowAPIKey,
)
if err := d.loadState(); err != nil {
return err