Test expanding chown value of COPY command
Signed-off-by: Hao Hu <hao.hu.fr@gmail.com>docker-19.03
parent
0248635269
commit
155bfa5a80
|
@ -713,9 +713,14 @@ func testCopyChownCreateDest(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
||||||
dockerfile := []byte(`
|
dockerfile := []byte(`
|
||||||
FROM busybox
|
FROM busybox
|
||||||
|
ARG group
|
||||||
|
ENV owner user01
|
||||||
RUN adduser -D user
|
RUN adduser -D user
|
||||||
|
RUN adduser -D user01
|
||||||
COPY --chown=user:user . /dest
|
COPY --chown=user:user . /dest
|
||||||
|
COPY --chown=${owner}:${group} . /dest01
|
||||||
RUN [ "$(stat -c "%U %G" /dest)" == "user user" ]
|
RUN [ "$(stat -c "%U %G" /dest)" == "user user" ]
|
||||||
|
RUN [ "$(stat -c "%U %G" /dest01)" == "user01 user" ]
|
||||||
`)
|
`)
|
||||||
|
|
||||||
dir, err := tmpdir(
|
dir, err := tmpdir(
|
||||||
|
@ -731,6 +736,7 @@ RUN [ "$(stat -c "%U %G" /dest)" == "user user" ]
|
||||||
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
|
_, err = f.Solve(context.TODO(), c, client.SolveOpt{
|
||||||
FrontendAttrs: map[string]string{
|
FrontendAttrs: map[string]string{
|
||||||
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
|
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
|
||||||
|
"build-arg:group": "user",
|
||||||
},
|
},
|
||||||
LocalDirs: map[string]string{
|
LocalDirs: map[string]string{
|
||||||
builder.DefaultLocalNameDockerfile: dir,
|
builder.DefaultLocalNameDockerfile: dir,
|
||||||
|
@ -2512,11 +2518,15 @@ func testCopyChown(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
||||||
dockerfile := []byte(`
|
dockerfile := []byte(`
|
||||||
FROM busybox AS base
|
FROM busybox AS base
|
||||||
|
ENV owner 1000
|
||||||
RUN mkdir -m 0777 /out
|
RUN mkdir -m 0777 /out
|
||||||
COPY --chown=daemon foo /
|
COPY --chown=daemon foo /
|
||||||
COPY --chown=1000:nogroup bar /baz
|
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" /foo > /out/fooowner
|
||||||
RUN stat -c "%u %G" /baz/sub > /out/subowner
|
RUN stat -c "%u %G" /baz/sub > /out/subowner
|
||||||
|
RUN stat -c "%u %G" /foobis > /out/foobisowner
|
||||||
FROM scratch
|
FROM scratch
|
||||||
COPY --from=base /out /
|
COPY --from=base /out /
|
||||||
`)
|
`)
|
||||||
|
@ -2547,6 +2557,7 @@ COPY --from=base /out /
|
||||||
},
|
},
|
||||||
FrontendAttrs: map[string]string{
|
FrontendAttrs: map[string]string{
|
||||||
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
|
"build-arg:BUILDKIT_DISABLE_FILEOP": strconv.FormatBool(!isFileOp),
|
||||||
|
"build-arg:group": "nogroup",
|
||||||
},
|
},
|
||||||
LocalDirs: map[string]string{
|
LocalDirs: map[string]string{
|
||||||
builder.DefaultLocalNameDockerfile: dir,
|
builder.DefaultLocalNameDockerfile: dir,
|
||||||
|
@ -2562,6 +2573,10 @@ COPY --from=base /out /
|
||||||
dt, err = ioutil.ReadFile(filepath.Join(destDir, "subowner"))
|
dt, err = ioutil.ReadFile(filepath.Join(destDir, "subowner"))
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, "1000 nogroup\n", string(dt))
|
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) {
|
func testCopyOverrideFiles(t *testing.T, sb integration.Sandbox) {
|
||||||
|
|
Loading…
Reference in New Issue