Skip to content

Feature add env#425

Open
rousbound wants to merge 7 commits intoferronweb:develop-2.xfrom
rousbound:feature-add-ENV
Open

Feature add env#425
rousbound wants to merge 7 commits intoferronweb:develop-2.xfrom
rousbound:feature-add-ENV

Conversation

@rousbound
Copy link

@rousbound rousbound commented Jan 17, 2026

Hi @DorianNiemiecSVRJS!

I've created this PR as a follow up of the discussion on issue #233 and the PR #236 .

I tried to follow the style of the previous PR on lookup_env_var.rs with the addition of:

  • Changes to kdl.rs adapter
  • Interpolation of env variables in lookup_env_var.rs

I appreciate any feedback.

Thanks in advance.

use anyhow::bail;
use std::env;

pub fn lookup_env_value(conf_string: String) -> anyhow::Result<String> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done cleaner with the regex crate, see here for example.

use std::env;

pub fn lookup_env_value(conf_string: String) -> anyhow::Result<String> {
if !conf_string.contains("{env:") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ferron config files look a lot like caddy config files. How about using the same syntax like the caddyfile "env" placeholders? See https://caddyserver.com/docs/conventions#placeholders .

}
}

#[cfg(test)]
Copy link
Contributor

@amejia1 amejia1 Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a way to escape the placeholder, for example \{env.HOME} should render {env.HOME}.

for kdl_entry in kdl_node.iter() {
let value = match kdl_entry.value().to_owned() {
KdlValue::String(value) => ServerConfigurationValue::String(value),
KdlValue::String(value) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will probably be best to render all placeholders first and then process the config files. Will this config work?

{env.HTTP_ADDRESS} {
    proxy "http://localhost:3000/" // Replace "http://localhost:3000" with the backend server URL
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants