Caddyfile and placeholders

I have a caddyfile which works

{$API_HOST}:9443 {
}

Does not work

{env.API_HOST}:9443 {
}

Which has gotten me thinking about the appropriate place to do variable replacements?

I am wondering if we should remove any of the replacement processes that the Caddyfile adapter does and instead pass these through to the underlying module. This would also mean that running the adapt command on the first Caddyfile would transform it into the second file. Currently this is being done in the Caddyfile itself. https://github.com/caddyserver/caddy/blob/master/caddyfile/parse.go#L419

Thoughts?

1 Like

Ah, I forgot about this, thanks for reminding me!

Yes, we should make the second one work.

In v1, we needed the env placeholders embedded into the Caddyfile parser, which I always kind of hated, but you’re right, I don’t think we need to do that in v2. Let’s just parse it like normal, and let the underlying module deal with the replacements. This will make the feature simpler, more consistent, more correct, and more useful.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.