exptypes: define empty gz layer digest

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-10-18 21:55:50 -07:00
parent f9d7f1cf4a
commit c8b8d6ce63
4 changed files with 11 additions and 16 deletions

View File

@ -4,15 +4,12 @@ import (
"fmt"
"sort"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
"github.com/moby/buildkit/solver"
digest "github.com/opencontainers/go-digest"
"github.com/pkg/errors"
)
const (
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
)
// sortConfig sorts the config structure to make sure it is deterministic
func sortConfig(cc *CacheConfig) {
type indexedLayer struct {
@ -242,7 +239,7 @@ func marshalRemote(r *solver.Remote, state *marshalState) string {
}
desc := r.Descriptors[len(r.Descriptors)-1]
if desc.Digest == emptyGZLayer {
if desc.Digest == exptypes.EmptyGZLayer {
return parentID
}

View File

@ -1,11 +1,16 @@
package exptypes
import specs "github.com/opencontainers/image-spec/specs-go/v1"
import (
"github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
)
const ExporterImageConfigKey = "containerimage.config"
const ExporterInlineCache = "containerimage.inlinecache"
const ExporterPlatformsKey = "refs.platforms"
const EmptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
type Platforms struct {
Platforms []Platform
}

View File

@ -27,10 +27,6 @@ import (
"golang.org/x/sync/errgroup"
)
const (
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
)
type WriterOpt struct {
Snapshotter snapshot.Snapshotter
ContentStore content.Store
@ -413,7 +409,7 @@ func normalizeLayersAndHistory(remote *solver.Remote, history []ocispec.History,
var layerIndex int
for i, h := range history {
if !h.EmptyLayer {
if remote.Descriptors[layerIndex].Digest == emptyGZLayer {
if remote.Descriptors[layerIndex].Digest == exptypes.EmptyGZLayer {
h.EmptyLayer = true
remote.Descriptors = append(remote.Descriptors[:layerIndex], remote.Descriptors[layerIndex+1:]...)
} else {

View File

@ -9,15 +9,12 @@ import (
"github.com/containerd/containerd/content"
"github.com/containerd/containerd/images"
"github.com/moby/buildkit/cache"
"github.com/moby/buildkit/exporter/containerimage/exptypes"
digest "github.com/opencontainers/go-digest"
specs "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
)
const (
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
)
type Opt struct {
ImageStore images.Store
ContentStore content.Store
@ -93,7 +90,7 @@ func toDigests(layers []specs.Descriptor) []digest.Digest {
func layerKey(layers []digest.Digest) string {
b := &strings.Builder{}
for _, l := range layers {
if l != emptyGZLayer {
if l != exptypes.EmptyGZLayer {
b.Write([]byte(l))
}
}