fix(configuration): an overlay stands in for a missing config file; dev overlay is complete

This commit is contained in:
sam committed 2026-10-04 03:47:17 +11:00
1 parent 164c40f37b
commit d53c20d209
4 files changed
+11 -2

No files matched your search

+2
View File
@@ -12,6 +12,8 @@
# fails closed without a PostgreSQL URL. This must reach the `postgres`
# service in docker-compose.yml, which `task dev` brings up first via
# dev:postgres -- keep the URL and that service in agreement.
bot_user = "archie-dev"
database_url = "postgres://archie:archie@127.0.0.1:5432/archie?sslmode=disable"
[web]
+1 -1
View File
@@ -80,7 +80,7 @@ func Resolve(o Options, log *slog.Logger) (ResolvedConfig, error) {
}
func readProjection(path, overlay string, log *slog.Logger) (projection, bool, error) {
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) && overlay == "" {
return projection{}, false, nil
}
doc, err := configuration.New(log).Resolve(path, overlay)
+1 -1
View File
@@ -41,7 +41,7 @@ func Resolve(o Options, log *slog.Logger) (Options, error) {
// the UI process is allowed to see. An absent source is not an error (the
// process is fully drivable by flags); an unreadable or invalid one is.
func readProjection(path, overlay string, log *slog.Logger) (projection, bool, error) {
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) {
if _, err := os.Stat(path); errors.Is(err, fs.ErrNotExist) && overlay == "" {
return projection{}, false, nil
}
doc, err := configuration.New(log).Resolve(path, overlay)
@@ -1,7 +1,9 @@
package configuration
import (
"errors"
"fmt"
"io/fs"
"log/slog"
"os"
"path/filepath"
@@ -96,6 +98,11 @@ func (l *Loader) File(path string) (*Document, error) {
// tooling share the exact same precedence and validation rules.
func (l *Loader) Resolve(basePath, overlayPath string) (*Document, error) {
info, err := os.Stat(basePath)
if errors.Is(err, fs.ErrNotExist) && overlayPath != "" {
// An overlay alone is a complete source: a dev stack runs without the
// operator's config file.
return l.Resolve(overlayPath, "")
}
if err != nil {
return nil, fmt.Errorf("%w: config source %s: %w", ErrUnreadable, basePath, err)
}