aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Magorsch <arzano@gentoo.org>2020-06-19 15:51:41 +0200
committerMax Magorsch <arzano@gentoo.org>2020-06-19 15:51:41 +0200
commit21181c518cf41828917d36005b726f9452fde657 (patch)
tree38fab1b3c86a41383e48be6b2686d92efd86db62 /pkg/config/config.go
downloadarchives-21181c518cf41828917d36005b726f9452fde657.tar.gz
archives-21181c518cf41828917d36005b726f9452fde657.tar.bz2
archives-21181c518cf41828917d36005b726f9452fde657.zip
Initial version
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go75
1 files changed, 75 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
new file mode 100644
index 0000000..70ab9cc
--- /dev/null
+++ b/pkg/config/config.go
@@ -0,0 +1,75 @@
+package config
+
+import (
+ "os"
+ "strings"
+)
+
+func MailDirPath() string {
+ mailDir := getEnv("ARCHIVES_MAILDIR_PATH", "/var/archives/.maildir/")
+ if !strings.HasSuffix(mailDir, "/") {
+ mailDir = mailDir + "/"
+ }
+ return mailDir
+}
+
+func Port() string {
+ return getEnv("ARCHIVES_PORT", "5000")
+}
+
+func PostgresUser() string {
+ return getEnv("ARCHIVES_POSTGRES_USER", "admin")
+}
+
+func PostgresPass() string {
+ return getEnv("ARCHIVES_POSTGRES_PASS", "admin")
+}
+
+func PostgresDb() string {
+ return getEnv("ARCHIVES_POSTGRES_DB", "garchives")
+}
+
+func PostgresHost() string {
+ return getEnv("ARCHIVES_POSTGRES_HOST", "localhost")
+}
+
+func PostgresPort() string {
+ return getEnv("ARCHIVES_POSTGRES_PORT", "5432")
+}
+
+func CacheControl() string {
+ return getEnv("ARCHIVES_CACHE_CONTROL", "max-age=300")
+}
+
+func IndexMailingLists() [][]string {
+ return [][]string{
+ {"gentoo-dev", "is the main technical development mailing list of Gentoo"},
+ {"gentoo-project", "contains non-technical discussion and propositions for the Gentoo Council"},
+ {"gentoo-announce", "contains important news for all Gentoo stakeholders"},
+ {"gentoo-user", "is our main support and Gentoo-related talk mailing list"},
+ {"gentoo-commits", " - Lots of commits"},
+ {"gentoo-dev-announce", "conveys important changes to all developers and interested users"}}
+}
+
+func AllPublicMailingLists() []string {
+ var allMailingLists []string
+ allMailingLists = append(allMailingLists, CurrentMailingLists()...)
+ allMailingLists = append(allMailingLists, FrozenArchives()...)
+ return allMailingLists
+}
+
+func CurrentMailingLists() []string {
+ return []string{"gentoo-announce", "gentoo-commits", "gentoo-dev", "gentoo-dev-announce", "gentoo-nfp", "gentoo-project", "gentoo-user"}
+}
+
+func FrozenArchives() []string {
+ return []string{"gentoo-arm", "gentoo-au", "gentoo-council", "gentoo-cygwin", "gentoo-desktop-research"}
+}
+
+func getEnv(key string, fallback string) string {
+ if os.Getenv(key) != "" {
+ return os.Getenv(key)
+ } else {
+ return fallback
+ }
+}