diff --git a/acceptance/acceptance_test.go b/acceptance/acceptance_test.go index d4c73f7a05..b1c845c1ef 100644 --- a/acceptance/acceptance_test.go +++ b/acceptance/acceptance_test.go @@ -2762,7 +2762,7 @@ func createStackImage(dockerCli client.CommonAPIClient, repoName string, dir str defaultFilterFunc := func(file string) bool { return true } ctx := context.Background() - buildContext := archive.ReadDirAsTar(dir, "/", 0, 0, -1, true, defaultFilterFunc) + buildContext := archive.ReadDirAsTar(dir, "/", 0, 0, -1, true, false, defaultFilterFunc) res, err := dockerCli.ImageBuild(ctx, buildContext, dockertypes.ImageBuildOptions{ Tags: []string{repoName}, diff --git a/acceptance/buildpacks/archive_buildpack.go b/acceptance/buildpacks/archive_buildpack.go index 311e274b50..3f1f4c2b14 100644 --- a/acceptance/buildpacks/archive_buildpack.go +++ b/acceptance/buildpacks/archive_buildpack.go @@ -74,6 +74,7 @@ func (a archiveBuildpack) createTgz(sourceDir string) (string, error) { defaultGid, defaultMode, true, + false, nil, ) if err != nil { diff --git a/inspect_buildpack_test.go b/inspect_buildpack_test.go index 6d93d373a7..f832f2e469 100644 --- a/inspect_buildpack_test.go +++ b/inspect_buildpack_test.go @@ -652,5 +652,5 @@ func writeBuildpackArchive(buildpackPath, tmpDir string, assert h.AssertionManag tw := tar.NewWriter(buildpackWriter) defer tw.Close() - assert.Nil(archive.WriteDirToTar(tw, layoutDir, "/", 0, 0, 0755, true, nil)) + assert.Nil(archive.WriteDirToTar(tw, layoutDir, "/", 0, 0, 0755, true, false, nil)) } diff --git a/internal/blob/blob.go b/internal/blob/blob.go index c32f669fb8..1846435c4f 100644 --- a/internal/blob/blob.go +++ b/internal/blob/blob.go @@ -31,7 +31,7 @@ func (b blob) Open() (r io.ReadCloser, err error) { return nil, errors.Wrapf(err, "read blob at path '%s'", b.path) } if fi.IsDir() { - return archive.ReadDirAsTar(b.path, ".", 0, 0, -1, true, nil), nil + return archive.ReadDirAsTar(b.path, ".", 0, 0, -1, true, false, nil), nil } fh, err := os.Open(b.path) diff --git a/internal/build/container_ops.go b/internal/build/container_ops.go index d0ae10f44d..fdc842e71f 100644 --- a/internal/build/container_ops.go +++ b/internal/build/container_ops.go @@ -25,14 +25,15 @@ import ( type ContainerOperation func(ctrClient client.CommonAPIClient, ctx context.Context, containerID string, stdout, stderr io.Writer) error // CopyDir copies a local directory (src) to the destination on the container while filtering files and changing it's UID/GID. -func CopyDir(src, dst string, uid, gid int, os string, fileFilter func(string) bool) ContainerOperation { +// if includeRoot is set the UID/GID will be set on the dst directory. +func CopyDir(src, dst string, uid, gid int, os string, includeRoot bool, fileFilter func(string) bool) ContainerOperation { return func(ctrClient client.CommonAPIClient, ctx context.Context, containerID string, stdout, stderr io.Writer) error { tarPath := dst if os == "windows" { tarPath = paths.WindowsToSlash(dst) } - reader, err := createReader(src, tarPath, uid, gid, fileFilter) + reader, err := createReader(src, tarPath, uid, gid, includeRoot, fileFilter) if err != nil { return errors.Wrapf(err, "create tar archive from '%s'", src) } @@ -166,7 +167,7 @@ func WriteStackToml(dstPath string, stack builder.StackMetadata, os string) Cont } } -func createReader(src, dst string, uid, gid int, fileFilter func(string) bool) (io.ReadCloser, error) { +func createReader(src, dst string, uid, gid int, includeRoot bool, fileFilter func(string) bool) (io.ReadCloser, error) { fi, err := os.Stat(src) if err != nil { return nil, err @@ -178,7 +179,7 @@ func createReader(src, dst string, uid, gid int, fileFilter func(string) bool) ( mode = 0777 } - return archive.ReadDirAsTar(src, dst, uid, gid, mode, false, fileFilter), nil + return archive.ReadDirAsTar(src, dst, uid, gid, mode, false, includeRoot, fileFilter), nil } return archive.ReadZipAsTar(src, dst, uid, gid, -1, false, fileFilter), nil diff --git a/internal/build/container_ops_test.go b/internal/build/container_ops_test.go index 790ce0dc15..12a07a226b 100644 --- a/internal/build/container_ops_test.go +++ b/internal/build/container_ops_test.go @@ -86,7 +86,7 @@ func testContainerOps(t *testing.T, when spec.G, it spec.S) { h.AssertNil(t, err) defer cleanupContainer(ctx, ctr.ID) - copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app"), containerDir, 123, 456, osType, nil) + copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app"), containerDir, 123, 456, osType, false, nil) var outBuf, errBuf bytes.Buffer err = copyDirOp(ctrClient, ctx, ctr.ID, &outBuf, &errBuf) @@ -124,6 +124,54 @@ lrwxrwxrwx 1 123 456 (.*) fake-app-symlink -> fake-app-file } }) + when("includeRoot", func() { + it("copies root dir with new GID, UID and permissions", func() { + containerDir := "/some-vol" + if osType == "windows" { + containerDir = `c:\some-vol` + } + + ctrCmd := []string{"ls", "-al", "/"} + if osType == "windows" { + ctrCmd = []string{"cmd", "/c", `dir /q c:`} + } + + ctx := context.Background() + ctr, err := createContainer(ctx, imageName, containerDir, osType, ctrCmd...) + h.AssertNil(t, err) + defer cleanupContainer(ctx, ctr.ID) + + copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app"), containerDir, 123, 456, osType, true, nil) + + var outBuf, errBuf bytes.Buffer + err = copyDirOp(ctrClient, ctx, ctr.ID, &outBuf, &errBuf) + h.AssertNil(t, err) + + err = container.Run(ctx, ctrClient, ctr.ID, &outBuf, &errBuf) + h.AssertNil(t, err) + + h.AssertEq(t, errBuf.String(), "") + if osType == "windows" { + // Expected WCOW results + h.AssertContainsMatch(t, strings.ReplaceAll(outBuf.String(), "\r", ""), ` +(.*) ... some-vol +`) + } else { + if runtime.GOOS == "windows" { + // Expected LCOW results + h.AssertContainsMatch(t, outBuf.String(), ` +drwxrwxrwx 2 123 456 (.*) some-vol +`) + } else { + // Expected results + h.AssertContainsMatch(t, outBuf.String(), ` +drwsrwsrwt 2 123 456 (.*) some-vol +`) + } + } + }) + }) + it("writes contents ignoring from file filter", func() { containerDir := "/some-vol" if osType == "windows" { @@ -140,7 +188,7 @@ lrwxrwxrwx 1 123 456 (.*) fake-app-symlink -> fake-app-file h.AssertNil(t, err) defer cleanupContainer(ctx, ctr.ID) - copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app"), containerDir, 123, 456, osType, func(filename string) bool { + copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app"), containerDir, 123, 456, osType, false, func(filename string) bool { return filepath.Base(filename) != "file-to-ignore" }) @@ -172,7 +220,7 @@ lrwxrwxrwx 1 123 456 (.*) fake-app-symlink -> fake-app-file h.AssertNil(t, err) defer cleanupContainer(ctx, ctr.ID) - copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app.zip"), containerDir, 123, 456, osType, nil) + copyDirOp := build.CopyDir(filepath.Join("testdata", "fake-app.zip"), containerDir, 123, 456, osType, false, nil) var outBuf, errBuf bytes.Buffer err = copyDirOp(ctrClient, ctx, ctr.ID, &outBuf, &errBuf) diff --git a/internal/build/lifecycle_execution.go b/internal/build/lifecycle_execution.go index e0d96ebc08..acb6c665d4 100644 --- a/internal/build/lifecycle_execution.go +++ b/internal/build/lifecycle_execution.go @@ -173,6 +173,7 @@ func (l *LifecycleExecution) Cleanup() error { func (l *LifecycleExecution) Create(ctx context.Context, publish bool, dockerHost string, clearCache bool, runImage, repoName, networkMode string, buildCache, launchCache Cache, additionalTags, volumes []string, phaseFactory PhaseFactory) error { flags := addTags([]string{ + "-app", l.mountPaths.appDir(), "-cache-dir", l.mountPaths.cacheDir(), "-run-image", runImage, }, additionalTags) @@ -200,7 +201,7 @@ func (l *LifecycleExecution) Create(ctx context.Context, publish bool, dockerHos WithArgs(repoName), WithNetwork(networkMode), cacheOpts, - WithContainerOperations(CopyDir(l.opts.AppPath, l.mountPaths.appDir(), l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, l.opts.FileFilter)), + WithContainerOperations(CopyDir(l.opts.AppPath, l.mountPaths.appDir(), l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, true, l.opts.FileFilter)), } if publish { @@ -224,6 +225,7 @@ func (l *LifecycleExecution) Create(ctx context.Context, publish bool, dockerHos } func (l *LifecycleExecution) Detect(ctx context.Context, networkMode string, volumes []string, phaseFactory PhaseFactory) error { + flags := []string{"-app", l.mountPaths.appDir()} configProvider := NewPhaseConfigProvider( "detector", l, @@ -235,8 +237,9 @@ func (l *LifecycleExecution) Detect(ctx context.Context, networkMode string, vol WithBinds(volumes...), WithContainerOperations( EnsureVolumeAccess(l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, l.layersVolume, l.appVolume), - CopyDir(l.opts.AppPath, l.mountPaths.appDir(), l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, l.opts.FileFilter), + CopyDir(l.opts.AppPath, l.mountPaths.appDir(), l.opts.Builder.UID(), l.opts.Builder.GID(), l.os, true, l.opts.FileFilter), ), + WithFlags(flags...), ) detect := phaseFactory.New(configProvider) @@ -357,6 +360,7 @@ func (l *LifecycleExecution) newAnalyze(repoName, networkMode string, publish bo } func (l *LifecycleExecution) Build(ctx context.Context, networkMode string, volumes []string, phaseFactory PhaseFactory) error { + flags := []string{"-app", l.mountPaths.appDir()} configProvider := NewPhaseConfigProvider( "builder", l, @@ -364,6 +368,7 @@ func (l *LifecycleExecution) Build(ctx context.Context, networkMode string, volu WithArgs(l.withLogLevel()...), WithNetwork(networkMode), WithBinds(volumes...), + WithFlags(flags...), ) build := phaseFactory.New(configProvider) @@ -382,6 +387,7 @@ func determineDefaultProcessType(platformAPI *api.Version, providedValue string) func (l *LifecycleExecution) newExport(repoName, runImage string, publish bool, dockerHost, networkMode string, buildCache, launchCache Cache, additionalTags []string, phaseFactory PhaseFactory) (RunnerCleaner, error) { flags := []string{ + "-app", l.mountPaths.appDir(), "-cache-dir", l.mountPaths.cacheDir(), "-stack", l.mountPaths.stackPath(), "-run-image", runImage, diff --git a/internal/build/lifecycle_execution_test.go b/internal/build/lifecycle_execution_test.go index ea26c0a6de..8fa5be5b52 100644 --- a/internal/build/lifecycle_execution_test.go +++ b/internal/build/lifecycle_execution_test.go @@ -151,6 +151,37 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { } } }) + when("Run with workspace dir", func() { + it("succeeds", func() { + opts := build.LifecycleOptions{ + Publish: false, + ClearCache: false, + RunImage: "test", + Image: imageName, + Builder: fakeBuilder, + TrustBuilder: true, + Workspace: "app", + UseCreator: true, + } + + lifecycle, err := build.NewLifecycleExecution(logger, docker, opts) + h.AssertNil(t, err) + + err = lifecycle.Run(context.Background(), func(execution *build.LifecycleExecution) build.PhaseFactory { + return fakePhaseFactory + }) + h.AssertNil(t, err) + + h.AssertEq(t, len(fakePhaseFactory.NewCalledWithProvider), 1) + + for _, entry := range fakePhaseFactory.NewCalledWithProvider { + if entry.Name() == "creator" { + h.AssertSliceContainsInOrder(t, entry.ContainerConfig().Cmd, "-app", "/app") + h.AssertSliceContains(t, entry.ContainerConfig().Cmd, "/some/image") + } + } + }) + }) }) when("Run without using creator", func() { it("succeeds", func() { @@ -183,29 +214,40 @@ func testLifecycleExecution(t *testing.T, when spec.G, it spec.S) { } } }) - }) + when("Run with workspace dir", func() { + it("succeeds", func() { + opts := build.LifecycleOptions{ + Publish: false, + ClearCache: false, + RunImage: "test", + Image: imageName, + Builder: fakeBuilder, + TrustBuilder: false, + Workspace: "app", + UseCreator: false, + } - when("Run with workspace dir", func() { - it("succeeds", func() { - opts := build.LifecycleOptions{ - Publish: false, - ClearCache: false, - RunImage: "test", - Image: imageName, - Builder: fakeBuilder, - TrustBuilder: false, - Workspace: "app", - UseCreator: true, - } + lifecycle, err := build.NewLifecycleExecution(logger, docker, opts) + h.AssertNil(t, err) + h.AssertEq(t, filepath.Base(lifecycle.AppDir()), "app") - lifecycle, err := build.NewLifecycleExecution(logger, docker, opts) - h.AssertNil(t, err) - h.AssertEq(t, filepath.Base(lifecycle.AppDir()), "app") + err = lifecycle.Run(context.Background(), func(execution *build.LifecycleExecution) build.PhaseFactory { + return fakePhaseFactory + }) + h.AssertNil(t, err) - err = lifecycle.Run(context.Background(), func(execution *build.LifecycleExecution) build.PhaseFactory { - return fakePhaseFactory + h.AssertEq(t, len(fakePhaseFactory.NewCalledWithProvider), 5) + + appCount := 0 + for _, entry := range fakePhaseFactory.NewCalledWithProvider { + switch entry.Name() { + case "detector", "builder", "exporter": + h.AssertSliceContainsInOrder(t, entry.ContainerConfig().Cmd, "-app", "/app") + appCount++ + } + } + h.AssertEq(t, appCount, 3) }) - h.AssertNil(t, err) }) }) diff --git a/internal/build/phase_test.go b/internal/build/phase_test.go index c29f71a277..3c00d8b192 100644 --- a/internal/build/phase_test.go +++ b/internal/build/phase_test.go @@ -150,6 +150,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) { lifecycleExec.Builder().UID(), lifecycleExec.Builder().GID(), osType, + false, nil, ), ), @@ -225,7 +226,7 @@ func testPhase(t *testing.T, when spec.G, it spec.S) { lifecycleExec, build.WithArgs("read", "/workspace/fake-app-file"), build.WithContainerOperations( - build.CopyDir(lifecycleExec.AppPath(), "/workspace", 0, 0, osType, nil), + build.CopyDir(lifecycleExec.AppPath(), "/workspace", 0, 0, osType, false, nil), ), )) h.AssertNil(t, err) @@ -437,7 +438,7 @@ func assertAppModTimePreserved(t *testing.T, lifecycle *build.LifecycleExecution lifecycle, build.WithArgs("read", "/workspace/fake-app-file"), build.WithContainerOperations( - build.CopyDir(lifecycle.AppPath(), "/workspace", 0, 0, osType, nil), + build.CopyDir(lifecycle.AppPath(), "/workspace", 0, 0, osType, false, nil), ), )) assertRunSucceeds(t, readPhase, outBuf, errBuf) diff --git a/internal/builder/builder_test.go b/internal/builder/builder_test.go index 2f9804ec02..2c8f8f10c3 100644 --- a/internal/builder/builder_test.go +++ b/internal/builder/builder_test.go @@ -61,7 +61,7 @@ func testBuilder(t *testing.T, when spec.G, it spec.S) { lifecycleTarReader := archive.ReadDirAsTar( filepath.Join("testdata", "lifecycle", "platform-0.4"), - ".", 0, 0, 0755, true, nil, + ".", 0, 0, 0755, true, false, nil, ) descriptorContents, err := ioutil.ReadFile(filepath.Join("testdata", "lifecycle", "platform-0.4", "lifecycle.toml")) diff --git a/internal/buildpackage/builder.go b/internal/buildpackage/builder.go index 2de28113e1..95e29a94ec 100644 --- a/internal/buildpackage/builder.go +++ b/internal/buildpackage/builder.go @@ -246,7 +246,7 @@ func (b *PackageBuilder) SaveAsFile(path, imageOS string) error { tw := tar.NewWriter(outputFile) defer tw.Close() - return archive.WriteDirToTar(tw, layoutDir, "/", 0, 0, 0755, true, nil) + return archive.WriteDirToTar(tw, layoutDir, "/", 0, 0, 0755, true, false, nil) } func (b *PackageBuilder) SaveAsImage(repoName string, publish bool, imageOS string) (imgutil.Image, error) { diff --git a/pkg/archive/archive.go b/pkg/archive/archive.go index 106a6c09c5..4ae235eae7 100644 --- a/pkg/archive/archive.go +++ b/pkg/archive/archive.go @@ -42,9 +42,9 @@ func (defaultTarWriterFactory) NewWriter(w io.Writer) TarWriter { return tar.NewWriter(w) } -func ReadDirAsTar(srcDir, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) io.ReadCloser { +func ReadDirAsTar(srcDir, basePath string, uid, gid int, mode int64, normalizeModTime, includeRoot bool, fileFilter func(string) bool) io.ReadCloser { return GenerateTar(func(tw TarWriter) error { - return WriteDirToTar(tw, srcDir, basePath, uid, gid, mode, normalizeModTime, fileFilter) + return WriteDirToTar(tw, srcDir, basePath, uid, gid, mode, normalizeModTime, includeRoot, fileFilter) }) } @@ -164,8 +164,20 @@ func ReadTarEntry(rc io.Reader, entryPath string) (*tar.Header, []byte, error) { } // WriteDirToTar writes the contents of a directory to a tar writer. `basePath` is the "location" in the tar the -// contents will be placed. -func WriteDirToTar(tw TarWriter, srcDir, basePath string, uid, gid int, mode int64, normalizeModTime bool, fileFilter func(string) bool) error { +// contents will be placed. The includeRoot param sets the permissions and metadata on the root file. +func WriteDirToTar(tw TarWriter, srcDir, basePath string, uid, gid int, mode int64, normalizeModTime, includeRoot bool, fileFilter func(string) bool) error { + if includeRoot { + rootHeader := &tar.Header{ + Typeflag: tar.TypeDir, + Name: basePath, + Mode: mode, + } + finalizeHeader(rootHeader, uid, gid, mode, normalizeModTime) + if err := tw.WriteHeader(rootHeader); err != nil { + return err + } + } + return filepath.Walk(srcDir, func(file string, fi os.FileInfo, err error) error { var relPath string if fileFilter != nil { diff --git a/pkg/archive/archive_test.go b/pkg/archive/archive_test.go index 100550e35f..79d73f69f1 100644 --- a/pkg/archive/archive_test.go +++ b/pkg/archive/archive_test.go @@ -55,7 +55,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { }) it("returns a TarReader of the dir", func() { - rc := archive.ReadDirAsTar(src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, nil) + rc := archive.ReadDirAsTar(src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, nil) tr := tar.NewReader(rc) verify := h.NewTarVerifier(t, tr, 1234, 2345) @@ -67,9 +67,17 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { h.AssertNil(t, rc.Close()) } }) + when("includeRoot", func() { + it("includes a modified root entry", func() { + rc := archive.ReadDirAsTar(src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, true, nil) + tr := tar.NewReader(rc) + verify := h.NewTarVerifier(t, tr, 1234, 2345) + verify.NextDirectory("/nested/dir/dir-in-archive", int64(os.ModePerm)) + }) + }) it("returns error if closed multiple times", func() { - rc := archive.ReadDirAsTar(src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, func(s string) bool { return false }) + rc := archive.ReadDirAsTar(src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, func(s string) bool { return false }) tr := tar.NewReader(rc) verify := h.NewTarVerifier(t, tr, 1234, 2345) verify.NoMoreFilesExist() @@ -189,7 +197,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, nil) + err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, nil) h.AssertNil(t, err) h.AssertNil(t, tw.Close()) h.AssertNil(t, fh.Close()) @@ -209,6 +217,29 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { }) }) + when("includeRoot is true", func() { + it("sets metadata on base dest file", func() { + fh, err := os.Create(filepath.Join(tmpDir, "some.tar")) + h.AssertNil(t, err) + + tw := tar.NewWriter(fh) + + err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, true, nil) + h.AssertNil(t, err) + h.AssertNil(t, tw.Close()) + h.AssertNil(t, fh.Close()) + + file, err := os.Open(filepath.Join(tmpDir, "some.tar")) + h.AssertNil(t, err) + defer file.Close() + + tr := tar.NewReader(file) + + verify := h.NewTarVerifier(t, tr, 1234, 2345) + verify.NextDirectory("/nested/dir/dir-in-archive", int64(os.ModePerm)) + }) + }) + when("mode is set to -1", func() { it("writes a tar to the dest dir with preexisting file mode", func() { fh, err := os.Create(filepath.Join(tmpDir, "some.tar")) @@ -216,7 +247,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, -1, true, nil) + err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, -1, true, false, nil) h.AssertNil(t, err) h.AssertNil(t, tw.Close()) h.AssertNil(t, fh.Close()) @@ -244,7 +275,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, func(path string) bool { + err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, func(path string) bool { return !strings.Contains(path, "some-file.txt") }) h.AssertNil(t, err) @@ -271,7 +302,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, func(path string) bool { + err = archive.WriteDirToTar(tw, src, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, func(path string) bool { return !strings.Contains(path, "dir-to-tar") }) h.AssertNil(t, err) @@ -301,7 +332,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/foo", 1234, 2345, 0777, false, nil) + err = archive.WriteDirToTar(tw, src, "/foo", 1234, 2345, 0777, false, false, nil) h.AssertNil(t, err) h.AssertNil(t, tw.Close()) h.AssertNil(t, fh.Close()) @@ -320,7 +351,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, src, "/foo", 1234, 2345, 0777, true, nil) + err = archive.WriteDirToTar(tw, src, "/foo", 1234, 2345, 0777, true, false, nil) h.AssertNil(t, err) h.AssertNil(t, tw.Close()) h.AssertNil(t, fh.Close()) @@ -367,7 +398,7 @@ func testArchive(t *testing.T, when spec.G, it spec.S) { tw := tar.NewWriter(fh) - err = archive.WriteDirToTar(tw, tmpSrcDir, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, nil) + err = archive.WriteDirToTar(tw, tmpSrcDir, "/nested/dir/dir-in-archive", 1234, 2345, 0777, true, false, nil) h.AssertNil(t, err) h.AssertNil(t, tw.Close()) h.AssertNil(t, fh.Close()) diff --git a/testhelpers/testhelpers.go b/testhelpers/testhelpers.go index cb6114f552..d574b0ca66 100644 --- a/testhelpers/testhelpers.go +++ b/testhelpers/testhelpers.go @@ -357,7 +357,7 @@ func CreateImage(t *testing.T, dockerCli client.CommonAPIClient, repoName, docke func CreateImageFromDir(t *testing.T, dockerCli client.CommonAPIClient, repoName string, dir string) { t.Helper() - buildContext := archive.ReadDirAsTar(dir, "/", 0, 0, -1, true, nil) + buildContext := archive.ReadDirAsTar(dir, "/", 0, 0, -1, true, false, nil) resp, err := dockerCli.ImageBuild(context.Background(), buildContext, dockertypes.ImageBuildOptions{ Tags: []string{repoName}, Remove: true, @@ -684,7 +684,7 @@ func writeTAR(t *testing.T, srcDir, tarDir string, mode int64, w io.Writer) { tw := tar.NewWriter(w) defer tw.Close() - err := archive.WriteDirToTar(tw, srcDir, tarDir, 0, 0, mode, true, nil) + err := archive.WriteDirToTar(tw, srcDir, tarDir, 0, 0, mode, true, false, nil) AssertNil(t, err) }