Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 24846d2

Browse files
authored
Use correct media type for zstd layers (#2459)
In my previous commits I forgot to override the media type for layers that are using zstd compression.
1 parent 76afb70 commit 24846d2

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

pkg/executor/build.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/google/go-containerregistry/pkg/v1/empty"
3232
"github.com/google/go-containerregistry/pkg/v1/mutate"
3333
"github.com/google/go-containerregistry/pkg/v1/tarball"
34+
"github.com/google/go-containerregistry/pkg/v1/types"
3435
"github.com/moby/buildkit/frontend/dockerfile/instructions"
3536
"github.com/pkg/errors"
3637
"github.com/sirupsen/logrus"
@@ -527,7 +528,7 @@ func (s *stageBuilder) saveSnapshotToLayer(tarPath string) (v1.Layer, error) {
527528

528529
switch s.opts.Compression {
529530
case config.ZStd:
530-
layerOpts = append(layerOpts, tarball.WithCompression("zstd"))
531+
layerOpts = append(layerOpts, tarball.WithCompression("zstd"), tarball.WithMediaType(types.OCILayerZStd))
531532

532533
case config.GZip:
533534
// layer already gzipped by default

pkg/executor/push.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import (
4141
"github.com/google/go-containerregistry/pkg/v1/remote"
4242
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
4343
"github.com/google/go-containerregistry/pkg/v1/tarball"
44+
"github.com/google/go-containerregistry/pkg/v1/types"
4445
"github.com/pkg/errors"
4546
"github.com/sirupsen/logrus"
4647
"github.com/spf13/afero"
@@ -307,7 +308,7 @@ func pushLayerToCache(opts *config.KanikoOptions, cacheKey string, tarPath strin
307308

308309
switch opts.Compression {
309310
case config.ZStd:
310-
layerOpts = append(layerOpts, tarball.WithCompression("zstd"))
311+
layerOpts = append(layerOpts, tarball.WithCompression("zstd"), tarball.WithMediaType(types.OCILayerZStd))
311312

312313
case config.GZip:
313314
// layer already gzipped by default

0 commit comments

Comments
 (0)