aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/config')
-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
+ }
+}