config: set all config values explicitly, with literal or (from-env ...)
This commit is contained in:
parent
723cc7233c
commit
8555d1740b
4 changed files with 11 additions and 13 deletions
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 ()
|
||||
|
|
Loading…
Add table
Reference in a new issue