Skip to content

Commit 09c9270

Browse files
committed
images: enable converter to uncompress zstd
Currently uncompress converter only supports gzip. This commit fixes it to support zstd as well. Signed-off-by: Kohei Tokunaga <[email protected]>
1 parent 5162238 commit 09c9270

10 files changed

Lines changed: 38 additions & 10 deletions

File tree

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ require (
4242
github.com/moby/sys/signal v0.5.1-0.20210723232958-8a51b5cc8879
4343
github.com/moby/sys/symlink v0.1.0
4444
github.com/opencontainers/go-digest v1.0.0
45-
github.com/opencontainers/image-spec v1.0.1
45+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
4646
github.com/opencontainers/runc v1.0.2
4747
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
4848
github.com/opencontainers/selinux v1.8.2

go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,9 @@ github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
431431
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
432432
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
433433
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
434-
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
435434
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
435+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283 h1:TVzvdjOalkJBNkbpPVMAr4KV9QRf2IjfxdyxwAK78Gs=
436+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
436437
github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg=
437438
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
438439
github.com/opencontainers/runtime-spec v1.0.2/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=

images/converter/uncompress/uncompress.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@
1717
package uncompress
1818

1919
import (
20-
"compress/gzip"
2120
"context"
2221
"fmt"
2322
"io"
2423

24+
"github.com/containerd/containerd/archive/compression"
2525
"github.com/containerd/containerd/content"
2626
"github.com/containerd/containerd/errdefs"
2727
"github.com/containerd/containerd/images"
@@ -49,7 +49,7 @@ func LayerConvertFunc(ctx context.Context, cs content.Store, desc ocispec.Descri
4949
}
5050
defer readerAt.Close()
5151
sr := io.NewSectionReader(readerAt, 0, desc.Size)
52-
newR, err := gzip.NewReader(sr)
52+
newR, err := compression.DecompressStream(sr)
5353
if err != nil {
5454
return nil, err
5555
}
@@ -112,9 +112,9 @@ func convertMediaType(mt string) string {
112112
return images.MediaTypeDockerSchema2Layer
113113
case images.MediaTypeDockerSchema2LayerForeignGzip:
114114
return images.MediaTypeDockerSchema2LayerForeign
115-
case ocispec.MediaTypeImageLayerGzip:
115+
case ocispec.MediaTypeImageLayerGzip, ocispec.MediaTypeImageLayerZstd:
116116
return ocispec.MediaTypeImageLayer
117-
case ocispec.MediaTypeImageLayerNonDistributableGzip:
117+
case ocispec.MediaTypeImageLayerNonDistributableGzip, ocispec.MediaTypeImageLayerNonDistributableZstd:
118118
return ocispec.MediaTypeImageLayerNonDistributable
119119
default:
120120
return mt

integration/client/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ require (
1414
github.com/containerd/typeurl v1.0.2
1515
github.com/gogo/protobuf v1.3.2
1616
github.com/opencontainers/go-digest v1.0.0
17-
github.com/opencontainers/image-spec v1.0.1
17+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
1818
github.com/opencontainers/runtime-spec v1.0.3-0.20210326190908-1c3f411f0417
1919
github.com/pkg/errors v0.9.1
2020
github.com/sirupsen/logrus v1.8.1

integration/client/go.sum

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,8 +400,9 @@ github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1y
400400
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
401401
github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U=
402402
github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM=
403-
github.com/opencontainers/image-spec v1.0.1 h1:JMemWkRwHx4Zj+fVxWoMCFm/8sYGGrUVojFA6h/TRcI=
404403
github.com/opencontainers/image-spec v1.0.1/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
404+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283 h1:TVzvdjOalkJBNkbpPVMAr4KV9QRf2IjfxdyxwAK78Gs=
405+
github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283/go.mod h1:BtxoFyWECRxE4U/7sNtV5W15zMzWCbyJoFRP3s7yZA0=
405406
github.com/opencontainers/runc v1.0.2 h1:opHZMaswlyxz1OuGpBE53Dwe4/xF7EZTY0A2L/FpCOg=
406407
github.com/opencontainers/runc v1.0.2/go.mod h1:aTaHFFwQXuA71CiyxOdFFIorAoemI04suvGRQFzWTD0=
407408
github.com/opencontainers/runtime-spec v1.0.1/go.mod h1:jwyrGlmzljRJv/Fgzds9SsS/C5hL+LL3ko9hs6T5lQ0=

vendor/github.com/opencontainers/image-spec/specs-go/v1/annotations.go

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/image-spec/specs-go/v1/config.go

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/image-spec/specs-go/v1/mediatype.go

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/opencontainers/image-spec/specs-go/version.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ github.com/modern-go/reflect2
302302
## explicit
303303
github.com/opencontainers/go-digest
304304
github.com/opencontainers/go-digest/digestset
305-
# github.com/opencontainers/image-spec v1.0.1
305+
# github.com/opencontainers/image-spec v1.0.2-0.20210819154149-5ad6f50d6283
306306
## explicit
307307
github.com/opencontainers/image-spec/identity
308308
github.com/opencontainers/image-spec/specs-go

0 commit comments

Comments
 (0)