Skip to content

Add environment variables interpolation#1390

Open
antonpetrov145 wants to merge 2 commits into
containers:mainfrom
antonpetrov145:env-vars-interploation
Open

Add environment variables interpolation#1390
antonpetrov145 wants to merge 2 commits into
containers:mainfrom
antonpetrov145:env-vars-interploation

Conversation

@antonpetrov145

Copy link
Copy Markdown
Contributor

Added the existing functionality to interpolate the environment set in compose.

Refers to 1384

@p12tic

p12tic commented Feb 16, 2026

Copy link
Copy Markdown
Collaborator

Tests are broken.

@antonpetrov145

Copy link
Copy Markdown
Contributor Author

@p12tic seems the tests are passing now, what got me confused are these lines

os.environ.update({
    key: value  # type: ignore[misc]
    for key, value in dotenv_dict.items()
    if key.startswith("PODMAN_")  # type: ignore[misc]
})
self.environ = dotenv_dict  # type: ignore[assignment]
self.environ.update(dict(os.environ))

when we have the dotenv_dict from file we set self.environ to it and then update with whatever we have in os.environ which means that everything gets replaced back, so my mistake was that I tried to set the dotenv_dict with the interpolated values, then update the whole os.environ object before it gets assigned back to self.environ which seems that broke the test for env files

now I set the interpolation to be done directly on the self.environ object, tell me if the logic is not correct, but now all values get interpolated and set correctly

@p12tic

p12tic commented Feb 21, 2026

Copy link
Copy Markdown
Collaborator

Seems that the PR is still incomplete because 2 lines above we have self.environ = <...>.

Also, it would be great to have integration tests that show in a reproducible way what exactly didn't work before and is now fixed.

@p12tic p12tic left a comment

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.

Marking as "request changes" for myself

@antonpetrov145

antonpetrov145 commented Feb 23, 2026

Copy link
Copy Markdown
Contributor Author

@p12tic you mean the lines above what I added right, I left those as they are because

self.environ = dotenv_dict  # here we are creating the self.environ obect

then here

self.environ.update(dict(os.environ))  # we are updating that with what we have in os.environ

and my change just interpolates the variables in the final object so there are no variables like $Abar

self.environ = rec_subs(dotenv_dict, dict(os.environ))

tell me if this logic is not correct, if I move the line above where we have the first assign, we will have the same result as now - variables are not interpolated because they are stored like that in os.environ

@marc2016

Copy link
Copy Markdown

This features looks great and would be super helpful! Thanks for working on this.

Is there anything I can do to help move this forward? I'd be happy to test this branch locally in my environment if that helps validate the changes.

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