Skip to content

feat: support nested defaults#1383

Open
GerkinDev wants to merge 2 commits intocontainers:mainfrom
GerkinDev:feat/nested-env-defaults
Open

feat: support nested defaults#1383
GerkinDev wants to merge 2 commits intocontainers:mainfrom
GerkinDev:feat/nested-env-defaults

Conversation

@GerkinDev
Copy link
Copy Markdown

Add support for nested env var interpolation

Signed-off-by: GerkinDev <alexandre.j.p.germain@gmail.com>
Comment thread podman_compose.py
if m.group("err") is not None:
raise RuntimeError(m.group("err"))
return m.group("default") or ""
raise RuntimeError(rec_subs(m.group("err"), subs_dict))
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure about this one.

Signed-off-by: GerkinDev <alexandre.j.p.germain@gmail.com>
@GerkinDev GerkinDev force-pushed the feat/nested-env-defaults branch from dcae156 to 97b7556 Compare January 27, 2026 13:42
@GerkinDev
Copy link
Copy Markdown
Author

While testing, I saw that some case were incorrect (for example: ${foo:-default} is ${bar-none}). It seems that a better regex is needed

Comment thread podman_compose.py
(?:{
(?P<braced>[_a-zA-Z][_a-zA-Z0-9]*)
(?:(?P<empty>:)?(?:
(?:-(?P<default>[^}]*)) |
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it's bad idea to allow this to match closing '}'.

We should do something like running the replacement algorithm multiple times.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeah I went this direction afterwards, this is still very much a work in progress.

Copy link
Copy Markdown
Collaborator

@p12tic p12tic left a comment

Choose a reason for hiding this comment

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

Marking as "request changes" for myself

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.

2 participants