There seems no way to pass dollar sign to atomic run via --opt1
When string with dollar sign is passed as value of --opt1 to atomic run, the string disappears.
Consider Dockerfile
FROM fedora
LABEL RUN 'docker run --rm ${IMAGE} echo the value: ${OPT1}'
For "normal" values it works:
# atomic run --opt1=jezek test-double-sub_env_strings
docker run --rm test-double-sub_env_strings echo the value: jezek
the value: jezek
But for values with dollar sign it does not:
# atomic run --opt1='$jezek' test-double-sub_env_strings
docker run --rm test-double-sub_env_strings echo the value:
the value:
I suspect the reason is
# Perform variable subs
in_string = os.path.expandvars(in_string)
# Replace undefined variables with blank
in_string = re.sub(r'\$\{?\S*\}?', '', in_string)
in sub_env_strings -- the re.sub replaces not just undefined variables, but also results of previous successful expandvars which put the $jezek there instead of ${OPT1}.
On related note, I'm also concerned by a double expansion attempts caused by
cmd = self.gen_cmd(args)
cmd = self.sub_env_strings(cmd)
self.display(cmd)
if self.args.display:
return
if not self.args.quiet:
self.check_args(cmd)
if not self.args.display:
util.check_call(self.sub_env_strings(cmd), env=self.cmd_env())
in https://github.com/projectatomic/atomic/blob/master/Atomic/run.py#L50. Note that there is
cmd = self.sub_env_strings(cmd), followed by util.check_call(self.sub_env_strings(cmd), ... -- the sub_env_strings is called twice.
@adelton Are we ok on this one? Can I close it or do you think we still need to change?
I'm not sure what the expected behaviour and handling of dollars should be.
I have atomic-1.13.1-1.el7.x86_64 and I see
# docker build -t issue-540 .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM fedora
---> 11a5107645d4
Step 2 : LABEL RUN 'docker run --rm ${IMAGE} echo the value: ${OPT1}'
---> Using cache
---> 084b61e41724
Successfully built 084b61e41724
# atomic run --opt1=jezek issue-540
docker run --rm issue-540 echo the value: jezek
the value: jezek
# atomic run --opt1='$jezek' issue-540
docker run --rm issue-540 echo the value:
the value:
#
So the issue does not seem to be fixed.
Is $jezek have a alue.?
If you do
jezek="foobar" atomic run --opt1='$jezek' issue-540 Do you get nothing?
Right, nothing as well:
# jezek="foobar" atomic run --opt1='$jezek' issue-540
docker run --rm issue-540 echo the value:
the value: