aboutsummaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-04-05 22:18:24 +0800
committerRunxi Yu <me@runxiyu.org>2025-04-05 22:19:40 +0800
commitf11775b3d292b1b119f7198d7e565749a4b9c847 (patch)
treea06c4ed6dfef919290af32d63683266377fc5f18 /config.go
parentUnexport some other things (diff)
downloadforge-f11775b3d292b1b119f7198d7e565749a4b9c847.tar.gz
forge-f11775b3d292b1b119f7198d7e565749a4b9c847.tar.zst
forge-f11775b3d292b1b119f7198d7e565749a4b9c847.zip
Move scfg into the repo and don't error out on unknown fields
Diffstat (limited to 'config.go')
-rw-r--r--config.go11
1 files changed, 6 insertions, 5 deletions
diff --git a/config.go b/config.go
index 5abbfb0..2158721 100644
--- a/config.go
+++ b/config.go
@@ -7,10 +7,11 @@ import (
"bufio"
"context"
"errors"
+ "log/slog"
"os"
- "codeberg.org/emersion/go-scfg"
"github.com/jackc/pgx/v5/pgxpool"
+ "go.lindenii.runxiyu.org/forge/internal/scfg"
)
type Config struct {
@@ -69,10 +70,7 @@ type Config struct {
// [config]; additional synchronization is necessary if the configuration is to
// be made reloadable.
//
-// TODO: Currently, it returns an error when the user specifies any unknown
-// configuration patterns, but silently ignores fields in the [config] struct
-// that is not present in the user's configuration file. We would prefer the
-// exact opposite behavior.
+// TODO: Error out when there are missing fields
func (s *Server) LoadConfig(path string) (err error) {
var configFile *os.File
if configFile, err = os.Open(path); err != nil {
@@ -84,6 +82,9 @@ func (s *Server) LoadConfig(path string) (err error) {
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")