-
Notifications
You must be signed in to change notification settings - Fork 106
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 support for KDL configuration #42
Conversation
Here's my current state, that I think I'm happy with. Here's the
And what it looks like in TOML (42 lines, 1226 characters): [system]
threads-per-service = 8
[[basic-proxy]]
name = "Example1"
[[basic-proxy.listeners]]
[basic-proxy.listeners.source]
kind = "Tcp"
[basic-proxy.listeners.source.value]
addr = "0.0.0.0:8080"
[[basic-proxy.listeners]]
[basic-proxy.listeners.source]
kind = "Tcp"
[basic-proxy.listeners.source.value]
addr = "0.0.0.0:4443"
[basic-proxy.listeners.source.value.tls]
cert_path = "./assets/test.crt"
key_path = "./assets/test.key"
[basic-proxy.connector]
proxy_addr = "91.107.223.4:443"
tls_sni = "onevariable.com"
[basic-proxy.path-control]
upstream-request-filters = [
{ kind = "remove-header-key-regex", pattern = ".*(secret|SECRET).*" },
{ kind = "upsert-header", key = "x-proxy-friend", value = "river" },
]
upstream-response-filters = [
{ kind = "remove-header-key-regex", pattern = ".*ETag.*" },
{ kind = "upsert-header", key = "x-with-love-from", value = "river" },
]
[[basic-proxy]]
name = "Example2"
listeners = [
{ source = { kind = "Tcp", value = { addr = "0.0.0.0:8000" } } }
]
connector = { proxy_addr = "91.107.223.4:80" } It's not necessarily as short as I expected it to be, but I think there's a lot of lines that are trailing braces ( |
Interestingly, this brings our configuration syntax MUCH closer to something like
HOWEVER, it is challenging in KDL to express a pattern like I don't think this is a blocker, but it might end up being a little "uncanny valley" for former NGINX users. |
As a heavy nginx user, this looks much better. Visibly, there is more configuration data in the file than configuration markup
This is a much smaller problem than you think. The Stating some options explicitly is somewhat okay. I guess, being able to just throw On the other hand: Is there something like configuration inheritance? Specifying a vHost will most likely still give all three listening sockets the same certificate. So, explicitly stating the same certificate for every endpoint somewhat redundant.
If KDL would not do this, you could also use YAML for this and offload the problem to the configuration language itself:
|
That's fair! I don't think this is a blocker, just something I was noting.
Built in to KDL: not specifically. We could invent something, but for as long as we can get away with it, I'd prefer to keep the configuration file parsing as simple as possible, to avoid accidentally making it turing complete :) We will likely also support JSON configuration in the future, and recommend that for anyone that needs to generate larger or dynamic configuration, or would like to build their own templating solution for configuration. |
On the one hand, this seems nice. But for configuration, I'd like to see for YAML. Main benefit: It allows comments and does not need another external (mostly self-written tool) to generate configuration. YAML allows 90% of the use users to use the default configuration format in raw. |
@bebehei I'm not totally against YAML, but support is likely not planned in the near future. Previous discussions here: The plan for now is to keep the core of the software flexible to allow us to support multiple configuration languages for now, as we focus on other core development tasks. |
I'm a very big fan of this syntax using KDL! Looks great - far more readable than the current toml config. |
Experimenting with KDL, as #39 will introduce quite a bit of nested configuration that may be difficult to manage in TOML.