Finished changing structure to modules:
- ntfy - keyserver - webhook - webserver functional modules.
This commit is contained in:
@@ -3,34 +3,46 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"os"
|
||||
|
||||
"varde/internal/ntfy"
|
||||
"varde/modules/keyserver"
|
||||
"varde/modules/webhook"
|
||||
"varde/modules/webserver"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
ContentDir string
|
||||
KeysDir string
|
||||
Port string
|
||||
RepoURL string
|
||||
RepoToken string
|
||||
WebhookSecret string
|
||||
NtfyURL string
|
||||
NtfyTopic string
|
||||
EnableWebhook bool
|
||||
Port string
|
||||
|
||||
Webserver webserver.Config
|
||||
Keyserver keyserver.Config
|
||||
Webhook webhook.Config
|
||||
Ntfy ntfy.Config
|
||||
}
|
||||
|
||||
func loadConfig() *Config {
|
||||
cfg := &Config{}
|
||||
|
||||
flag.StringVar(&cfg.ContentDir, "content-dir", envOrDefault("CONTENT_DIR", "./content"), "directory to serve as content")
|
||||
flag.StringVar(&cfg.KeysDir, "keys-dir", envOrDefault("KEYS_DIR", "./keys"), "directory to serve as WKD keys")
|
||||
flag.StringVar(&cfg.Port, "port", envOrDefault("PORT", "80"), "port to listen on")
|
||||
flag.StringVar(&cfg.RepoURL, "repo-url", envOrDefault("REPO_URL", ""), "git repo URL for webhook auto-update")
|
||||
flag.StringVar(&cfg.RepoToken, "repo-token", envOrDefault("REPO_TOKEN", ""), "git repo access token")
|
||||
flag.StringVar(&cfg.WebhookSecret, "webhook-secret", envOrDefault("WEBHOOK_SECRET", ""), "HMAC secret for webhook validation")
|
||||
flag.StringVar(&cfg.NtfyURL, "ntfy-url", envOrDefault("NTFY_URL", ""), "ntfy server URL for failure notifications")
|
||||
flag.StringVar(&cfg.NtfyTopic, "ntfy-topic", envOrDefault("NTFY_TOPIC", ""), "ntfy topic for failure notifications")
|
||||
flag.BoolVar(&cfg.EnableWebhook, "webhook", envOrDefaultBool("ENABLE_WEBHOOK", false), "enable git-webhook auto-update feature")
|
||||
|
||||
flag.BoolVar(&cfg.Webserver.Enabled, "enable-webserver", envOrDefaultBool("ENABLE_WEBSERVER", false), "enable static webserver module")
|
||||
flag.StringVar(&cfg.Webserver.ContentDir, "content-dir", envOrDefault("CONTENT_DIR", "./content"), "directory to serve as content")
|
||||
|
||||
flag.BoolVar(&cfg.Keyserver.Enabled, "enable-keyserver", envOrDefaultBool("ENABLE_KEYSERVER", false), "enable WKD keyserver module")
|
||||
flag.StringVar(&cfg.Keyserver.KeysDir, "keys-dir", envOrDefault("KEYS_DIR", "./keys"), "directory to serve as WKD keys")
|
||||
|
||||
flag.BoolVar(&cfg.Webhook.Enabled, "enable-webhook", envOrDefaultBool("ENABLE_WEBHOOK", false), "enable git-webhook auto-update module")
|
||||
flag.StringVar(&cfg.Webhook.RepoURL, "repo-url", envOrDefault("REPO_URL", ""), "git repo URL for webhook auto-update")
|
||||
flag.StringVar(&cfg.Webhook.RepoToken, "repo-token", envOrDefault("REPO_TOKEN", ""), "git repo access token")
|
||||
flag.StringVar(&cfg.Webhook.WebhookSecret, "webhook-secret", envOrDefault("WEBHOOK_SECRET", ""), "HMAC secret for webhook validation")
|
||||
|
||||
flag.StringVar(&cfg.Ntfy.URL, "ntfy-url", envOrDefault("NTFY_URL", ""), "ntfy server URL for failure notifications")
|
||||
flag.StringVar(&cfg.Ntfy.Topic, "ntfy-topic", envOrDefault("NTFY_TOPIC", ""), "ntfy topic for failure notifications")
|
||||
|
||||
flag.Parse()
|
||||
|
||||
// webhook pulls into the same directory the webserver serves
|
||||
cfg.Webhook.ContentDir = cfg.Webserver.ContentDir
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user