MCPcopy Index your code
hub / github.com/docker/cli / TestRunBuildResetsUidAndGidInContext

Function TestRunBuildResetsUidAndGidInContext

cli/command/image/build_test.go:59–87  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

57}
58
59func TestRunBuildResetsUidAndGidInContext(t *testing.T) {
60 skip.If(t, os.Getuid() != 0, "root is required to chown files")
61 t.Setenv("DOCKER_BUILDKIT", "0")
62 fakeBuild := newFakeBuild()
63 cli := test.NewFakeCli(&fakeClient{imageBuildFunc: fakeBuild.build})
64
65 dir := fs.NewDir(t, "test-build-context",
66 fs.WithFile("foo", "some content", fs.AsUser(65534, 65534)),
67 fs.WithFile("Dockerfile", `
68 FROM alpine:frozen
69 COPY foo bar /
70 `),
71 )
72 defer dir.Remove()
73
74 options := newBuildOptions()
75 options.context = dir.Path()
76 assert.NilError(t, runBuild(context.TODO(), cli, options))
77
78 headers := fakeBuild.headers(t)
79 expected := []*tar.Header{
80 {Name: "Dockerfile"},
81 {Name: "foo"},
82 }
83 cmpTarHeaderNameAndOwner := cmp.Comparer(func(x, y tar.Header) bool {
84 return x.Name == y.Name && x.Uid == y.Uid && x.Gid == y.Gid
85 })
86 assert.DeepEqual(t, expected, headers, cmpTarHeaderNameAndOwner)
87}
88
89func TestRunBuildDockerfileOutsideContext(t *testing.T) {
90 t.Setenv("DOCKER_BUILDKIT", "0")

Callers

nothing calls this directly

Calls 6

newFakeBuildFunction · 0.85
newBuildOptionsFunction · 0.85
runBuildFunction · 0.85
headersMethod · 0.80
RemoveMethod · 0.65
PathMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…