mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 15:28:35 +00:00
Add support for more advanced ${xxx:...} syntax
Just ${xxx:+...} and ${xxx:-...} for now
Signed-off-by: Doug Davis <dug@us.ibm.com>
This commit is contained in:
@@ -214,13 +214,19 @@ func TestBuildEnvironmentReplacementAddCopy(t *testing.T) {
|
||||
ENV baz foo
|
||||
ENV quux bar
|
||||
ENV dot .
|
||||
ENV fee fff
|
||||
ENV gee ggg
|
||||
|
||||
ADD ${baz} ${dot}
|
||||
COPY ${quux} ${dot}
|
||||
ADD ${zzz:-${fee}} ${dot}
|
||||
COPY ${zzz:-${gee}} ${dot}
|
||||
`,
|
||||
map[string]string{
|
||||
"foo": "test1",
|
||||
"bar": "test2",
|
||||
"fff": "test3",
|
||||
"ggg": "test4",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
@@ -286,6 +292,11 @@ func TestBuildEnvironmentReplacementEnv(t *testing.T) {
|
||||
if parts[1] != "zzz" {
|
||||
t.Fatalf("%s should be 'foo' but instead its %q", parts[0], parts[1])
|
||||
}
|
||||
} else if strings.HasPrefix(parts[0], "env") {
|
||||
envCount++
|
||||
if parts[1] != "foo" {
|
||||
t.Fatalf("%s should be 'foo' but instead its %q", parts[0], parts[1])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4069,6 +4080,27 @@ RUN [ "$abc" = "'foo'" ]
|
||||
ENV abc \"foo\"
|
||||
RUN [ "$abc" = '"foo"' ]
|
||||
|
||||
ENV abc=ABC
|
||||
RUN [ "$abc" = "ABC" ]
|
||||
ENV def=${abc:-DEF}
|
||||
RUN [ "$def" = "ABC" ]
|
||||
ENV def=${ccc:-DEF}
|
||||
RUN [ "$def" = "DEF" ]
|
||||
ENV def=${ccc:-${def}xx}
|
||||
RUN [ "$def" = "DEFxx" ]
|
||||
ENV def=${def:+ALT}
|
||||
RUN [ "$def" = "ALT" ]
|
||||
ENV def=${def:+${abc}:}
|
||||
RUN [ "$def" = "ABC:" ]
|
||||
ENV def=${ccc:-\$abc:}
|
||||
RUN [ "$def" = '$abc:' ]
|
||||
ENV def=${ccc:-\${abc}:}
|
||||
RUN [ "$def" = '${abc:}' ]
|
||||
ENV mypath=${mypath:+$mypath:}/home
|
||||
RUN [ "$mypath" = '/home' ]
|
||||
ENV mypath=${mypath:+$mypath:}/away
|
||||
RUN [ "$mypath" = '/home:/away' ]
|
||||
|
||||
ENV e1=bar
|
||||
ENV e2=$e1
|
||||
ENV e3=$e11
|
||||
|
||||
Reference in New Issue
Block a user