Skip to content

Commit

Permalink
fix(executor): export snapshotted layers of OCI images as OCI mediaTypes
Browse files Browse the repository at this point in the history
quick and dirrty fix for GoogleContainerTools#1836 ?
  • Loading branch information
kfix committed Feb 20, 2023
1 parent fe2413e commit 7c29f6f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion pkg/executor/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/go-containerregistry/pkg/v1/types"
"github.com/moby/buildkit/frontend/dockerfile/instructions"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
Expand Down Expand Up @@ -516,11 +517,21 @@ func (s *stageBuilder) saveSnapshotToLayer(tarPath string) (v1.Layer, error) {
}

var layer v1.Layer
img_mt, _ := s.image.MediaType()
is_oci_image := ( img_mt == types.OCIManifestSchema1 )
// or is it types.OCIConfigJSON or types.OCIContentDescriptor or types.OCIImageIndex ??
if s.opts.CompressedCaching == true {
layer, err = tarball.LayerFromFile(tarPath, tarball.WithCompressedCaching)
if is_oci_image {
layer, err = tarball.LayerFromFile(tarPath, tarball.WithCompressedCaching, tarball.WithMediaType(types.OCILayer))
} else {
layer, err = tarball.LayerFromFile(tarPath, tarball.WithCompressedCaching)
}
} else if is_oci_image {
layer, err = tarball.LayerFromFile(tarPath, tarball.WithMediaType(types.OCIUncompressedLayer))
} else {
layer, err = tarball.LayerFromFile(tarPath)
}

if err != nil {
return nil, err
}
Expand Down

0 comments on commit 7c29f6f

Please sign in to comment.