-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Allow . in variables used for interpolation
#1127
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
Allow . in variables used for interpolation
#1127
Conversation
| ) | ||
|
|
||
| var delimiter = "\\$" | ||
| var substitution = "[_a-z][_a-z0-9]*(?::?[-?][^}]*)?" |
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 is only said that do not begin with a digit, so starting with . is valid? 🤔
So the regexp could be: [_a-z.][_a-z0-9.]*(?::?[-?][^}]*)? ?
And by the way a small nit:
var(
delimiter = ...
substitution = ...
patternString = ...
pattern = ...
)> Environment variable names used by the utilities in the Shell and > Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase > letters, digits, and the '_' (underscore) from the characters > defined in Portable Character Set and do not begin with a > digit. **Other characters may be permitted by an implementation; > applications shall tolerate the presence of such names**. Uppercase > and lowercase letters shall retain their unique identities and shall > not be folded together. The name space of environment variable names > containing lowercase letters is reserved for applications. As it is possible to use them in environment variable, we should also allow them during interpolation. It's also required if we want to allow smarter interpolation in the future (and for `docker/app` too 👼) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
91c9224 to
318812e
Compare
silvin-lubecki
left a comment
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.
LGTM
|
SGTM, but want to check if there's additional rules when using substitution (also wondering if we could somehow share code that's used in the builder (thinking of moby/moby#37134) |
|
@vdemeester sorry if it's obvious, but I don't understand the usecase :S can you give an example of what this would enable? |
|
So, on a POSIX shell, this is definitely not working. # export some.odd.var=foo
sh: 1: export: some.odd.var: bad variable name
# echo ${some.odd.var:-bla}
sh: 2: Bad substitutionSo I'm a bit on the fence for this one; we removed validation for Looking for things where this could (potentially) be troublesome, it looks like currently it won't, but did notice this pattern-matching example in the documentation; http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html#tag_02_06_02_01, looks |
|
@tiborvass the main use case I can think of is for version: "3.2"
services:
vote:
image: ${vote.image.name}:${vote.image.tag}
ports:
- ${vote.port}:80
networks:
- frontend
depends_on:
- redis
deploy:
replicas: ${vote.replicas}
update_config:
parallelism: 2
restart_policy:
condition: on-failureAs @thaJeztah said, I'm a bit on the fence too for that (at least for supporting it in |
|
@vdemeester is there anything preventing from doing |
|
Hm, so wonder if we're conflating |
|
@tiborvass not really except UX — i.e. the settings file behind a yaml struct, it feels normal to use it as such in the variables (i.e. with the @thaJeztah we definitely are in a way 😝. But the interpolation in the composefile happens to be By doing that PR, I wish(ed) to make composefile used in |
If I'm not mistaken, docker/distribution uses underscores as separator for overriding options in the config-file, so that could still be an option. Could be problematic if the property itself already has an underscore... |
|
I'm going to close this one, as https://github.com/docker/cli/pull/1128/files#diff-0b0330d93ba7beed4c771a2bb1b79ce3R42 will allow advanced usage of the template/interpolation and allow to customize the pattern used. |
As it is possible to use them in environment variable, we should also
allow them during interpolation.
It's also required if we want to allow smarter interpolation in the
future (and for
docker/apptoo 👼)🦁
Signed-off-by: Vincent Demeester vincent@sbr.pm