Test expanding chown value of COPY command

Signed-off-by: Hao Hu <hao.hu.fr@gmail.com>
docker-19.03
Hao Hu 2019-04-06 23:01:55 +02:00
parent 0248635269
commit 155bfa5a80
1 changed files with 15 additions and 0 deletions

View File

@ -713,9 +713,14 @@ func testCopyChownCreateDest(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox
ARG group
ENV owner user01
RUN adduser -D user
RUN adduser -D user01
COPY --chown=user:user . /dest
COPY --chown=${owner}:${group} . /dest01
RUN [ "$(stat -c "%U %G" /dest)" == "user user" ]
RUN [ "$(stat -c "%U %G" /dest01)" == "user01 user" ]
`)
dir, err := tmpdir(
@ -731,6 +736,7 @@ RUN [ "$(stat -c "%U %G" /dest)" == "user user" ]
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
FrontendAttrs: map[string]string{
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
"build-arg:group": "user",
},
LocalDirs: map[string]string{
builder.DefaultLocalNameDockerfile: dir,
@ -2512,11 +2518,15 @@ func testCopyChown(t *testing.T, sb integration.Sandbox) {
dockerfile := []byte(`
FROM busybox AS base
ENV owner 1000
RUN mkdir -m 0777 /out
COPY --chown=daemon foo /
COPY --chown=1000:nogroup bar /baz
ARG group
COPY --chown=${owner}:${group} foo /foobis
RUN stat -c "%U %G" /foo > /out/fooowner
RUN stat -c "%u %G" /baz/sub > /out/subowner
RUN stat -c "%u %G" /foobis > /out/foobisowner
FROM scratch
COPY --from=base /out /
`)
@ -2547,6 +2557,7 @@ COPY --from=base /out /
},
FrontendAttrs: map[string]string{
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
"build-arg:group": "nogroup",
},
LocalDirs: map[string]string{
builder.DefaultLocalNameDockerfile: dir,
@ -2562,6 +2573,10 @@ COPY --from=base /out /
dt, err = ioutil.ReadFile(filepath.Join(destDir, "subowner"))
require.NoError(t, err)
require.Equal(t, "1000 nogroup\n", string(dt))
dt, err = ioutil.ReadFile(filepath.Join(destDir, "foobisowner"))
require.NoError(t, err)
require.Equal(t, "1000 nogroup\n", string(dt))
}
func testCopyOverrideFiles(t *testing.T, sb integration.Sandbox) {