Skip to content

Expand parameter substitution to support both :- and - - #12

Closed
dopry wants to merge 2 commits into
dnephin:inplace_var_defaultsfrom
dopry:inplace_var_defaults
Closed

dopry wants to merge 2 commits into
dnephin:inplace_var_defaultsfrom
dopry:inplace_var_defaults

Conversation

@dopry

@dopry dopry commented Mar 17, 2016

Copy link
Copy Markdown

I'd really like to see this make it in and you already have a PR open. I'm having trouble testing locally on windows, mounts don't work with the docker containers quite like I'd expect.

cheers.

Signed-off-by: Daniel Nephin <[email protected]>
Comment thread compose/config/interpolation.py Outdated
var, _, default = named.partition('-')
val = mapping.get(var, default)
else:
val = mapping[named]

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

There's some duplication here in the top two branches which I think we can remove.

I also prefer early returns instead of elif/else blocks.

@dnephin

dnephin commented Mar 17, 2016

Copy link
Copy Markdown
Owner

Thanks for the PR.

My PR isn't going to make it into 1.7.0 because code freeze is happening in a few days. So we have lots of time to get this into the next release.

@dopry
dopry force-pushed the inplace_var_defaults branch from d0bf233 to 5d5b3de Compare March 17, 2016 21:54
@dopry
dopry force-pushed the inplace_var_defaults branch from 5d5b3de to fdf6c88 Compare March 17, 2016 21:57
@dopry

dopry commented Mar 17, 2016

Copy link
Copy Markdown
Author

I've pushed a squashed version. I was able to run tests locally with tox. The unit tests are passing and I've switched back to early returns.

@dopry

dopry commented Mar 17, 2016

Copy link
Copy Markdown
Author

It'd be nice to see it make it into 1.7, but I understand if it can't. This is something we really struggle with where compose doesn't work well with a purist 12 factors approach where you want a set of environment defaults.

Even the priority of the various environment vars is strange compared to docker itself. In docker the environment vars are overridden with a priority hierarchy. The priorities for docker are from highest priority to lowest command line specified, shell specified, Dockerfile specified. Where in compose the compose file takes precedence over the shell environment and they cannot be set on the command line. You can specify an alternative env_file... The difference in how the environment vars are handled between the two is a little disorienting in all honesty.

@dnephin

dnephin commented Mar 18, 2016

Copy link
Copy Markdown
Owner

The Dockerfile and compose file are very different things, I wouldn't expect them to behave the same way.

@dopry

dopry commented Mar 18, 2016

Copy link
Copy Markdown
Author

The differences in the files is secondary to the more salient point that
docker-compose handles environment variable resolution differently than
docker when starting a container.

With docker run or docker-compose run there may have been environment
variables declared in the Dockerfile or docker-compose.yml respectively,
but I can always override them with -e.

docker-compose up/build lack that particular feature, which is why this PR
is an important step toward creating a more consistent user experience and
conceptual parity between the different tools that are in the docker
sphere. I think it's a good interim in that it's less invasive and allows
people to hack it now until the overall docker tooling universe becomes
more consistent and mature. Integration is a slow process after all.

ᐧ

On Fri, Mar 18, 2016 at 12:33 PM, Daniel Nephin [email protected]
wrote:

The Dockerfile and compose file are very different things, I wouldn't
expect them to behave the same way.

—
You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#12 (comment)

Darrel O'Pry
The Spry Group, LLC.
http://www.spry-group.com
718-355-9767 x101

@dnephin
dnephin force-pushed the inplace_var_defaults branch 2 times, most recently from 9c4f9cd to b00a451 Compare September 29, 2016 16:18
@dnephin

dnephin commented Sep 29, 2016

Copy link
Copy Markdown
Owner

Thanks for working on this. It looks like we might be getting this feature into Compose 1.9.

I ended up adding a similar change to my PR.

@dnephin dnephin closed this Sep 29, 2016
@dopry
dopry deleted the inplace_var_defaults branch September 29, 2016 16:29
@dopry

dopry commented Sep 29, 2016

Copy link
Copy Markdown
Author

No worries, thanks for the upstream work.
ᐧ

On Thu, Sep 29, 2016 at 12:20 PM, Daniel Nephin [email protected]
wrote:

Closed #12 #12.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#12 (comment), or mute the
thread
https://github.com/notifications/unsubscribe-auth/AAXqOL2YrKW_0uuy4hoJDSaj9vJTZC8tks5qu-U6gaJpZM4HzWxI
.

Darrel O'Pry
The Spry Group, LLC.
http://www.spry-group.com
718-355-9767 x101

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