-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
caddyfile: Add support for env var defaults, tests #3682
caddyfile: Add support for env var defaults, tests #3682
Conversation
7f9e13e
to
119c8e2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I'm alright with this. Thanks!
Is the bash-ism :-
just to keep things easier to remember so you don't have to learn a second syntax? (Because we're def. not bash)
As for the redundant ExpandEnv + Getenv, why is fixing it a breaking change?
Note the reviewdog comment
Someone could be specifically using that behaviour 🤷♂️ But if you're okay with fixing that, I can.
I guess. What alternative syntax would you suggest? |
I am more familiar with I'm not saying that's what we should do, it's just more intuitive to me personally, and it looks better. |
How about |
I'd be fine with that too. Honestly I guess I don't care if it's |
119c8e2
to
b91c651
Compare
Alright decided to go ahead with I also removed the "chaining" behaviour since I really doubt anyone actually relies on it, frankly. I just wanted to be safe by preserving it but it should be fine. We'll need to remember to note that whitespace around the Also we have #3807 in the pipeline which uses Anyways, according to https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_10_02 it seems that a regexp for env vars could look like: |
I think
lol, I also just reopened this thread with the intent of linking to that issue. My OCD is bothered that one uses |
Now I have another idea. Doesn't something like Once I settle my mind on the syntax I'm good with merging this. |
Sure, that's fine to me. Just FYI, shells use |
b91c651
to
18696ff
Compare
K I've made up my mind, let's use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh you already implemented it. K I guess we're good then.
Support variable expansion also in placeholders, like in `{unsetPlaceholder:default value}`. Implemented similarly to caddyserver#3682, which provided defaults for environment variable expansion. Closes caddyserver#1793. Signed-off-by: Jens Erat <jens.erat@mercedes-benz.com>
Support variable expansion also in placeholders, like in `{unsetPlaceholder:default value}`. Implemented similarly to caddyserver#3682, which provided defaults for environment variable expansion. Closes caddyserver#1793. Signed-off-by: Jens Erat <jens.erat@mercedes-benz.com>
Closes #2313
This adds support for an optional default in Caddyfile environment variable placeholders with a
:
separator. This is specifically for the ones like{$FOO}
, not the ones like{env.FOO}
which are replaced at runtime.For example:
If the
DOMAIN
environment variable exists, the site label will be set to the value of that environment variable, but if not set, will be set tolocalhost
.FYI @mholt I also noticed while working on this that we were doing
os.GetEnv
and feeding that intoos.ExpandEnv
, which actually means that the env var will be replaced twice in chain. I retained this behaviour for now and added a test for it, but it feels like that wasn't intentional. It would technically be a minor breaking change to fix it so I want to wait for your input.