config: set all config values explicitly, with literal or (from-env ...)

This commit is contained in:
Helmut Merz 2025-02-27 19:07:58 +01:00
parent 723cc7233c
commit 8555d1740b
4 changed files with 11 additions and 13 deletions

View file

@ -5,12 +5,10 @@
(config:root :env-keys '(:docroot :address :port :loglevel :logfile)
:env-path (util:runtime-path ".env"))
(config:add :logger
:class 'logging:config
(config:add :logger :class 'logging:config
:console nil)
(config:add :server
:class 'server:config
(config:add :server :class 'server:config
:port "8800"
:address "0.0.0.0"
:routes

View file

@ -93,7 +93,7 @@
;;;; utility functions
(defun from-env (key default)
(defun from-env (key &optional (default ""))
(or (gethash key (env-data *root*)) default))
(defun path (s &key env-key)

View file

@ -4,5 +4,10 @@
(in-package :scopes/test-config)
(config:root :class 'test-config)
(config:add :child :class 'child-config)
(config:root
:env-keys '(:user :password)
:env-path (t:test-path ".test.env"))
(config:add :child :class 'child-config
:user (config:from-env :user)
:password (config:from-env :password))

View file

@ -12,13 +12,8 @@
(in-package :scopes/test-config)
(defclass test-config (config:root)
((config:env-keys :initform '(:user :password))
(config:env-path :initform (t:test-path ".test.env"))))
(defclass child-config (config:base)
((config:env-slots :initform '(user password))
(user :accessor user :initarg :user)
((user :accessor user :initarg :user)
(password :accessor password :initarg :password)))
(defun run ()