-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add basic CUE definitions of Caddy config structure #2
base: master
Are you sure you want to change the base?
Conversation
In regards to the
Lesson: use So with that, running { "admin": { "disabled": false, "enforce_origin": false }, "logging": { "logs": { "log0": { "writer": { "output": "discard" }, "encoder": { "format": "json", "message_key": "some_key" } } } }, "apps": { "http": { "servers": { "srv0": { "listen": [ "80", "443" ], "routes": [ { "handle": [ { "handler": "static_response", "status_code": "200", "body": "Hello!" } ] } ] }, "srv1": { "listen": [ "80", "443" ], "routes": [ { "handle": [ { "handler": "static_response", "status_code": "200", "body": "Hello!" } ] } ] } } } } } Produces this config (notice how the default logger is injected in and other default values are injected too): { "admin": { "disabled": false, "listen": "localhost:2019", "enforce_origin": false, "config": { "persist": true } }, "logging": { "logs": { "default": { "level": "INFO", "writer": { "output": "stderr" }, "encoder": { "format": "json" }, "sampling": { "interval": 1000000000, "first": 100, "thereafter": 100 } }, "log0": { "level": "INFO", "writer": { "output": "discard" }, "encoder": { "format": "json", "message_key": "some_key" } } } }, "apps": { "http": { "servers": { "srv0": { "listen": [ "80", "443" ], "routes": [ { "handle": [ { "body": "Hello!", "handler": "static_response", "status_code": "200" } ] } ] }, "srv1": { "listen": [ "80", "443" ], "routes": [ { "handle": [ { "body": "Hello!", "handler": "static_response", "status_code": "200" } ] } ] } } } } } The latest pending issue I have currently is merging the values of the default logger with the config provided by the user. Meaning, if the user has config values for the default logger, it should override/merge against the default hard-coded values of matching keys. |
Warning: I'm building this as I'm learning/exploring CUE. It is very likely it's not done with best practices. Review/guidance is very welcome and needed!
This seems to work... to a point. The two sample config files I'm using exhibit 2 behaviors:
1- One seems to work fine and filled with default values for missing fields
2- The other.... causes CUE to panic with stack overflow (I know the change that caused it to start panicking)
Successful
Running
cue eval *.cue -d Config --out json caddy.json
against this config:Failed
Running
cue eval *.cue -d Config --out json caddy.json
against this config:Results in this output:
Removing the default indicator
*
from*"json"
and*KeyedEncoder
inlog.cue
resolves the stack overflow.