package config import ( "flag" "os" ) const ( dsnOsStr = "BIZDEX_DSN" dsnDefault = "bizdex.db" ) type UsagePolicy struct { Name string `json:"name"` Noun string `json:"noun"` Verb string `json:"verb"` Subject string `json:"subject"` Extra string `json:"extra"` ExtraType string `json:"extra_type"` Windows string `json:"windows"` } type AddrChange struct { Address string Port uint16 } type Config struct { Title string `json:"title"` SupportEmail string `json:"support_email"` SupportPhone string `json:"support_phone"` Purpose string `json:"purpose"` Disclaimer string `json:"disclaimer"` MaxDefaultBusinesses int `json:"max_default_businesses"` SignupNeedsApprove bool `json:"signup_needs_approve"` ListenAddress string `json:"listen_address"` Port uint16 `json:"port"` LocaleMapPic []byte `json:"locale_map_pic"` SessionLengthMax int `json:"session_length_max"` EmailConfirm bool `json:"email_confirm"` EmailRegex string `json:"email_regex"` EmailRequired bool `json:"email_required"` PasswordSaltLength int `json:"password_salt_length"` PasswordKeyLength int `json:"password_key_length"` PasswordRounds int `json:"password_rounds"` PasswordHashStrategy string `json:"password_hash_strategy"` PasswordAttempts int `json:"password_attempts"` PasswordMin int `json:"password_min"` PasswordRegex string `json:"password_regex"` PasswordHelp string `json:"password_help"` PasswordRequired bool `json:"password_required"` LogAddSource bool `json:"log_add_source"` LogLevel string `json:"log_level"` LogLevelKey string `json:"log_level_key"` LogLevelOverrides string `json:"log_level_overrides"` LogTimeFormat string `json:"log_time_format"` LogTimeKey string `json:"log_time_key"` ConfigReloadSeconds uint `json:"config_reload_seconds"` PersonStyleTextColor string `json:"person_style_text_color"` PersonStyleTextDarkColor string `json:"person_style_text_dark_color"` PersonStyleBackgroundColor string `json:"person_style_background_color"` PersonStyleBackgroundDarkColor string `json:"person_style_background_dark_color"` UsagePolicies map[string]*UsagePolicy `json:"usage_policies"` } func GetDsn() string { dsnStrP := flag.String("dsn", dsnDefault, "path to sqlite db file. If not set, try to read BIZDEX_DSN env var. If not set, default value used") flag.Parse() if dsnStrP == nil { os.Exit(1) } dsnStr := *dsnStrP if dsnStr == dsnDefault { if osDsn := os.Getenv(dsnOsStr); osDsn != "" { dsnStr = osDsn } } return dsnStr }