diff --git a/internal/configuration/configuration.go b/internal/configuration/configuration.go index 01bdf3d..23ad512 100644 --- a/internal/configuration/configuration.go +++ b/internal/configuration/configuration.go @@ -48,8 +48,38 @@ func (c Config) LoadFromDisk() error { return fmt.Errorf("failed to unmarshal config file: %w", err) } + c.checkConfig() + slog.Debug("successfully read config file", "path", ConfigFile) return nil } + +func (c Config) checkConfig() { + failed := false + if c.ApiEndpoint == "" { + slog.Error("[CONFIG] api_endpoint must not be empty") + failed = true + } + + if c.ApiKey == "" { + slog.Error("[CONFIG] api_key must not be empty") + failed = true + } + + if c.AdminEmail == "" { + slog.Error("[CONFIG] admin_email must not be empty") + failed = true + } + + if len(c.MailPrefixes) < 1 { + slog.Error("[CONFIG] mail_prefixes must have at least one entry") + failed = true + } + + if failed { + slog.Error("[CONFIG] Application can't start until above errors are fixed.") + os.Exit(1) + } +}