aboutsummaryrefslogtreecommitdiff
path: root/internal/unsorted/config.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-06 09:26:46 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-06 09:27:53 +0800
commitda1d8f4e7c332c7109427915e6459b10209cedce (patch)
tree280b921be3b51f93d82d916b4eaa89387b7102cc /internal/unsorted/config.go
parentgit2c, git2d: Rename cmd1 and cmd2 descriptively (diff)
downloadforge-da1d8f4e7c332c7109427915e6459b10209cedce.tar.gz
forge-da1d8f4e7c332c7109427915e6459b10209cedce.tar.zst
forge-da1d8f4e7c332c7109427915e6459b10209cedce.zip
Move the Go stuff to ./forged/v0.1.32
Diffstat (limited to 'internal/unsorted/config.go')
-rw-r--r--internal/unsorted/config.go90
1 files changed, 0 insertions, 90 deletions
diff --git a/internal/unsorted/config.go b/internal/unsorted/config.go
deleted file mode 100644
index a2c0eb7..0000000
--- a/internal/unsorted/config.go
+++ /dev/null
@@ -1,90 +0,0 @@
-// SPDX-License-Identifier: AGPL-3.0-only
-// SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
-
-package unsorted
-
-import (
- "bufio"
- "errors"
- "log/slog"
- "os"
-
- "go.lindenii.runxiyu.org/forge/internal/database"
- "go.lindenii.runxiyu.org/forge/internal/irc"
- "go.lindenii.runxiyu.org/forge/internal/scfg"
-)
-
-type Config struct {
- HTTP struct {
- Net string `scfg:"net"`
- Addr string `scfg:"addr"`
- CookieExpiry int `scfg:"cookie_expiry"`
- Root string `scfg:"root"`
- ReadTimeout uint32 `scfg:"read_timeout"`
- WriteTimeout uint32 `scfg:"write_timeout"`
- IdleTimeout uint32 `scfg:"idle_timeout"`
- ReverseProxy bool `scfg:"reverse_proxy"`
- } `scfg:"http"`
- Hooks struct {
- Socket string `scfg:"socket"`
- Execs string `scfg:"execs"`
- } `scfg:"hooks"`
- LMTP struct {
- Socket string `scfg:"socket"`
- Domain string `scfg:"domain"`
- MaxSize int64 `scfg:"max_size"`
- WriteTimeout uint32 `scfg:"write_timeout"`
- ReadTimeout uint32 `scfg:"read_timeout"`
- } `scfg:"lmtp"`
- Git struct {
- RepoDir string `scfg:"repo_dir"`
- Socket string `scfg:"socket"`
- DaemonPath string `scfg:"daemon_path"`
- } `scfg:"git"`
- SSH struct {
- Net string `scfg:"net"`
- Addr string `scfg:"addr"`
- Key string `scfg:"key"`
- Root string `scfg:"root"`
- } `scfg:"ssh"`
- IRC irc.Config `scfg:"irc"`
- General struct {
- Title string `scfg:"title"`
- } `scfg:"general"`
- DB struct {
- Type string `scfg:"type"`
- Conn string `scfg:"conn"`
- } `scfg:"db"`
-}
-
-// LoadConfig loads a configuration file from the specified path and unmarshals
-// it to the global [config] struct. This may race with concurrent reads from
-// [config]; additional synchronization is necessary if the configuration is to
-// be made reloadable.
-func (s *Server) loadConfig(path string) (err error) {
- var configFile *os.File
- if configFile, err = os.Open(path); err != nil {
- return err
- }
- defer configFile.Close()
-
- decoder := scfg.NewDecoder(bufio.NewReader(configFile))
- if err = decoder.Decode(&s.config); err != nil {
- return err
- }
- for _, u := range decoder.UnknownDirectives() {
- slog.Warn("unknown configuration directive", "directive", u)
- }
-
- if s.config.DB.Type != "postgres" {
- return errors.New("unsupported database type")
- }
-
- if s.database, err = database.Open(s.config.DB.Conn); err != nil {
- return err
- }
-
- s.globalData["forge_title"] = s.config.General.Title
-
- return nil
-}