Browse code

remove uses of deprecated go-archive consts

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2025/12/20 01:51:03
Showing 14 changed files
... ...
@@ -8,6 +8,7 @@ import (
8 8
 
9 9
 	"github.com/moby/go-archive"
10 10
 	"github.com/moby/go-archive/chrootarchive"
11
+	"github.com/moby/go-archive/compression"
11 12
 	containertypes "github.com/moby/moby/api/types/container"
12 13
 	"github.com/moby/moby/api/types/events"
13 14
 	"github.com/moby/moby/v2/daemon/container"
... ...
@@ -278,7 +279,7 @@ func (daemon *Daemon) containerCopy(container *container.Container, resource str
278 278
 		filter = []string{f}
279 279
 	}
280 280
 	archv, err := chrootarchive.Tar(basePath, &archive.TarOptions{
281
-		Compression:  archive.Uncompressed,
281
+		Compression:  compression.None,
282 282
 		IncludeFiles: filter,
283 283
 	}, container.BaseFS)
284 284
 	if err != nil {
... ...
@@ -7,6 +7,7 @@ import (
7 7
 
8 8
 	"github.com/moby/buildkit/frontend/dockerfile/instructions"
9 9
 	"github.com/moby/go-archive"
10
+	"github.com/moby/go-archive/compression"
10 11
 	"github.com/moby/moby/v2/daemon/builder/remotecontext"
11 12
 	"github.com/moby/sys/reexec"
12 13
 	"gotest.tools/v3/assert"
... ...
@@ -105,7 +106,7 @@ func TestDispatch(t *testing.T) {
105 105
 				createTestTempFile(t, contextDir, filename, content, 0o777)
106 106
 			}
107 107
 
108
-			tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
108
+			tarStream, err := archive.Tar(contextDir, compression.None)
109 109
 			if err != nil {
110 110
 				t.Fatalf("Error when creating tar stream: %s", err)
111 111
 			}
... ...
@@ -7,6 +7,7 @@ import (
7 7
 	"testing"
8 8
 
9 9
 	"github.com/moby/go-archive"
10
+	"github.com/moby/go-archive/compression"
10 11
 	"github.com/moby/moby/api/types/container"
11 12
 	"github.com/moby/moby/api/types/network"
12 13
 	"github.com/moby/moby/v2/daemon/builder"
... ...
@@ -61,7 +62,7 @@ func readAndCheckDockerfile(t *testing.T, testName, contextDir, dockerfilePath,
61 61
 	if runtime.GOOS != "windows" {
62 62
 		skip.If(t, os.Getuid() != 0, "skipping test that requires root")
63 63
 	}
64
-	tarStream, err := archive.Tar(contextDir, archive.Uncompressed)
64
+	tarStream, err := archive.Tar(contextDir, compression.None)
65 65
 	assert.NilError(t, err)
66 66
 
67 67
 	defer func() {
... ...
@@ -6,6 +6,7 @@ import (
6 6
 
7 7
 	"github.com/containerd/log"
8 8
 	"github.com/moby/go-archive"
9
+	"github.com/moby/go-archive/compression"
9 10
 	"github.com/moby/moby/v2/daemon/builder"
10 11
 	"github.com/moby/moby/v2/daemon/builder/remotecontext/git"
11 12
 )
... ...
@@ -17,7 +18,7 @@ func MakeGitContext(gitURL string) (builder.Source, error) {
17 17
 		return nil, err
18 18
 	}
19 19
 
20
-	c, err := archive.Tar(root, archive.Uncompressed)
20
+	c, err := archive.Tar(root, compression.None)
21 21
 	if err != nil {
22 22
 		return nil, err
23 23
 	}
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"testing"
7 7
 
8 8
 	"github.com/moby/go-archive"
9
+	"github.com/moby/go-archive/compression"
9 10
 	"github.com/moby/moby/v2/daemon/builder"
10 11
 	"github.com/moby/sys/reexec"
11 12
 	"github.com/pkg/errors"
... ...
@@ -128,7 +129,7 @@ func TestRemoveDirectory(t *testing.T) {
128 128
 
129 129
 func makeTestArchiveContext(t *testing.T, dir string) builder.Source {
130 130
 	skip.If(t, os.Getuid() != 0, "skipping test that requires root")
131
-	tarStream, err := archive.Tar(dir, archive.Uncompressed)
131
+	tarStream, err := archive.Tar(dir, compression.None)
132 132
 	if err != nil {
133 133
 		t.Fatalf("error: %s", err)
134 134
 	}
... ...
@@ -15,6 +15,7 @@ import (
15 15
 	cerrdefs "github.com/containerd/errdefs"
16 16
 	"github.com/containerd/platforms"
17 17
 	"github.com/moby/go-archive"
18
+	"github.com/moby/go-archive/compression"
18 19
 	"github.com/moby/moby/v2/daemon/server/imagebackend"
19 20
 	"github.com/moby/moby/v2/internal/testutil/labelstore"
20 21
 	"github.com/moby/moby/v2/internal/testutil/specialimage"
... ...
@@ -39,7 +40,7 @@ func TestImageLoad(t *testing.T) {
39 39
 	imgSvc.defaultPlatformOverride = platforms.Only(linuxAmd64)
40 40
 
41 41
 	tryLoad := func(ctx context.Context, t *testing.T, dir string, platformList []ocispec.Platform) error {
42
-		tarRc, err := archive.Tar(dir, archive.Uncompressed)
42
+		tarRc, err := archive.Tar(dir, compression.None)
43 43
 		assert.NilError(t, err)
44 44
 		defer tarRc.Close()
45 45
 
... ...
@@ -9,6 +9,7 @@ import (
9 9
 	"github.com/containerd/log"
10 10
 	"github.com/moby/go-archive"
11 11
 	"github.com/moby/go-archive/chrootarchive"
12
+	"github.com/moby/go-archive/compression"
12 13
 	"github.com/moby/moby/api/types/events"
13 14
 	"github.com/moby/moby/v2/daemon/container"
14 15
 	"github.com/moby/moby/v2/errdefs"
... ...
@@ -65,7 +66,7 @@ func (daemon *Daemon) containerExport(ctx context.Context, ctr *container.Contai
65 65
 	}()
66 66
 
67 67
 	archv, err := chrootarchive.Tar(basefs, &archive.TarOptions{
68
-		Compression: archive.Uncompressed,
68
+		Compression: compression.None,
69 69
 		IDMap:       daemon.idMapping,
70 70
 	}, basefs)
71 71
 	if err != nil {
... ...
@@ -8,6 +8,7 @@ import (
8 8
 	"github.com/containerd/log"
9 9
 	"github.com/moby/go-archive"
10 10
 	"github.com/moby/go-archive/chrootarchive"
11
+	"github.com/moby/go-archive/compression"
11 12
 	"github.com/moby/moby/v2/pkg/ioutils"
12 13
 	"github.com/moby/sys/user"
13 14
 )
... ...
@@ -64,7 +65,7 @@ func (gdw *NaiveDiffDriver) Diff(id, parent string) (arch io.ReadCloser, retErr
64 64
 	}()
65 65
 
66 66
 	if parent == "" {
67
-		tarArchive, err := archive.Tar(layerFs, archive.Uncompressed)
67
+		tarArchive, err := archive.Tar(layerFs, compression.None)
68 68
 		if err != nil {
69 69
 			return nil, err
70 70
 		}
... ...
@@ -19,6 +19,7 @@ import (
19 19
 	"github.com/docker/go-units"
20 20
 	"github.com/moby/go-archive"
21 21
 	"github.com/moby/go-archive/chrootarchive"
22
+	"github.com/moby/go-archive/compression"
22 23
 	"github.com/moby/locker"
23 24
 	"github.com/moby/moby/v2/daemon/graphdriver"
24 25
 	"github.com/moby/moby/v2/daemon/graphdriver/overlayutils"
... ...
@@ -721,7 +722,7 @@ func (d *Driver) Diff(id, parent string) (io.ReadCloser, error) {
721 721
 	diffPath := d.getDiffPath(id)
722 722
 	logger.Debugf("Tar with options on %s", diffPath)
723 723
 	return archive.TarWithOptions(diffPath, &archive.TarOptions{
724
-		Compression:    archive.Uncompressed,
724
+		Compression:    compression.None,
725 725
 		IDMap:          d.idMap,
726 726
 		WhiteoutFormat: archive.OverlayWhiteoutFormat,
727 727
 	})
... ...
@@ -17,6 +17,7 @@ import (
17 17
 	"github.com/distribution/reference"
18 18
 	"github.com/docker/distribution"
19 19
 	"github.com/moby/go-archive"
20
+	"github.com/moby/go-archive/compression"
20 21
 	"github.com/moby/moby/api/types/events"
21 22
 	"github.com/moby/moby/v2/daemon/internal/image"
22 23
 	v1 "github.com/moby/moby/v2/daemon/internal/image/v1"
... ...
@@ -395,7 +396,7 @@ func (s *saveSession) writeTar(ctx context.Context, tempDir string, outStream io
395 395
 	ctx, span := tracing.StartSpan(ctx, "writeTar")
396 396
 	defer span.End()
397 397
 
398
-	fs, err := archive.Tar(tempDir, archive.Uncompressed)
398
+	fs, err := archive.Tar(tempDir, compression.None)
399 399
 	if err != nil {
400 400
 		span.SetStatus(err)
401 401
 		return err
... ...
@@ -12,6 +12,7 @@ import (
12 12
 
13 13
 	"github.com/containerd/continuity/driver"
14 14
 	"github.com/moby/go-archive"
15
+	"github.com/moby/go-archive/compression"
15 16
 	"github.com/moby/moby/v2/daemon/graphdriver"
16 17
 	"github.com/moby/moby/v2/daemon/graphdriver/vfs"
17 18
 	"github.com/moby/moby/v2/daemon/internal/stringid"
... ...
@@ -587,7 +588,7 @@ func tarFromFiles(files ...FileApplier) ([]byte, error) {
587 587
 		}
588 588
 	}
589 589
 
590
-	r, err := archive.Tar(td, archive.Uncompressed)
590
+	r, err := archive.Tar(td, compression.None)
591 591
 	if err != nil {
592 592
 		return nil, err
593 593
 	}
... ...
@@ -2025,11 +2025,11 @@ CMD ["cat", "/foo"]`),
2025 2025
 }
2026 2026
 
2027 2027
 func (s *DockerCLIBuildSuite) TestBuildContextTarGzip(c *testing.T) {
2028
-	testContextTar(c, archive.Gzip)
2028
+	testContextTar(c, compression.Gzip)
2029 2029
 }
2030 2030
 
2031 2031
 func (s *DockerCLIBuildSuite) TestBuildContextTarNoCompression(c *testing.T) {
2032
-	testContextTar(c, archive.Uncompressed)
2032
+	testContextTar(c, compression.None)
2033 2033
 }
2034 2034
 
2035 2035
 func (s *DockerCLIBuildSuite) TestBuildNoContext(c *testing.T) {
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"time"
11 11
 
12 12
 	"github.com/moby/go-archive"
13
+	"github.com/moby/go-archive/compression"
13 14
 	"github.com/moby/moby/api/types/events"
14 15
 	plugintypes "github.com/moby/moby/api/types/plugin"
15 16
 	"github.com/moby/moby/api/types/registry"
... ...
@@ -209,7 +210,7 @@ func makePluginBundle(inPath string, opts ...CreateOpt) (io.ReadCloser, error) {
209 209
 	if err := archive.NewDefaultArchiver().CopyFileWithTar(cfg.binPath, filepath.Join(inPath, "rootfs", p.Entrypoint[0])); err != nil {
210 210
 		return nil, errors.Wrap(err, "error copying plugin binary to rootfs path")
211 211
 	}
212
-	tar, err := archive.Tar(inPath, archive.Uncompressed)
212
+	tar, err := archive.Tar(inPath, compression.None)
213 213
 	return tar, errors.Wrap(err, "error making plugin archive")
214 214
 }
215 215
 
... ...
@@ -11,6 +11,7 @@ import (
11 11
 	"github.com/distribution/reference"
12 12
 	"github.com/google/uuid"
13 13
 	"github.com/moby/go-archive"
14
+	"github.com/moby/go-archive/compression"
14 15
 	"github.com/opencontainers/go-digest"
15 16
 	"github.com/opencontainers/image-spec/specs-go"
16 17
 	ocispec "github.com/opencontainers/image-spec/specs-go/v1"
... ...
@@ -137,7 +138,7 @@ func fileArchive(dir string, name string, content []byte) (io.ReadCloser, error)
137 137
 		return nil, err
138 138
 	}
139 139
 
140
-	return archive.Tar(tmp, archive.Uncompressed)
140
+	return archive.Tar(tmp, compression.None)
141 141
 }
142 142
 
143 143
 func writeLayerWithOneFile(dir string, filename string, content []byte) (ocispec.Descriptor, error) {