-
Notifications
You must be signed in to change notification settings - Fork 15
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
Expand env variables in volume paths in configuration file #192
Conversation
For more context on this change, see #191.
While working on this feature, I hit a case where the 'warnings' module was referenced, but this caused a NameError because the module was never imported. AFAICT this issue has been present since the code was introduced, but it was never noticed because it was behind a conditional that was never satisfied.
3a85fce
to
14019c8
Compare
Responding to a comment on GH-192, the code now calls string.Template.substitute, which has more correct behavior because it won't skip expanding any unset environmental variables. Now, the behavior is to raise an exception, similar to bash's nounset (set -u) option. This code was placed in 'utils.py' so that it can be used elsewhere in Scuba and not just config-parsing code.
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.
Thanks for the update. I found a few more issues.
Also, change all instances of 'environmental variables' to 'environment variables', as that is the accepted terminology (which I didn't know up to this point!)
This includes mocking the environment variables instead of modifying the global environment during unit tests, and adding extra tests for the underlying expansion function in `utils.py`.
I added documentation for this functionality change in 850f6b0. The only backward-incompatability issue we may have is that if any users have the |
Thanks a lot @xanarin for your patience and the high-quality code! |
@@ -166,6 +166,19 @@ of volume options: | |||
hostpath: /host/foo | |||
options: ro,cached | |||
|
|||
The keys used in volume mappings can contain environment variables **that are |
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.
It's actually not just the keys (container path), but also the host path, which can contain environment vars (as shown in the example)
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.
Opened #214 to fix
volumes: | ||
$TEST_HOME/.config/application1: $TEST_HOME/.config/application1 | ||
|
||
Note that because variable expansion is now applied to all volume keys, if one |
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.
keys -> paths
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.
Opened #214 to fix
For more context on this change, see #191.