exptypes: define empty gz layer digest
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>v0.8
parent
f9d7f1cf4a
commit
c8b8d6ce63
|
@ -4,15 +4,12 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
|
"github.com/moby/buildkit/exporter/containerimage/exptypes"
|
||||||
"github.com/moby/buildkit/solver"
|
"github.com/moby/buildkit/solver"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
|
|
||||||
)
|
|
||||||
|
|
||||||
// sortConfig sorts the config structure to make sure it is deterministic
|
// sortConfig sorts the config structure to make sure it is deterministic
|
||||||
func sortConfig(cc *CacheConfig) {
|
func sortConfig(cc *CacheConfig) {
|
||||||
type indexedLayer struct {
|
type indexedLayer struct {
|
||||||
|
@ -242,7 +239,7 @@ func marshalRemote(r *solver.Remote, state *marshalState) string {
|
||||||
}
|
}
|
||||||
desc := r.Descriptors[len(r.Descriptors)-1]
|
desc := r.Descriptors[len(r.Descriptors)-1]
|
||||||
|
|
||||||
if desc.Digest == emptyGZLayer {
|
if desc.Digest == exptypes.EmptyGZLayer {
|
||||||
return parentID
|
return parentID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,16 @@
|
||||||
package exptypes
|
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 ExporterImageConfigKey = "containerimage.config"
|
||||||
const ExporterInlineCache = "containerimage.inlinecache"
|
const ExporterInlineCache = "containerimage.inlinecache"
|
||||||
const ExporterPlatformsKey = "refs.platforms"
|
const ExporterPlatformsKey = "refs.platforms"
|
||||||
|
|
||||||
|
const EmptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
|
||||||
|
|
||||||
type Platforms struct {
|
type Platforms struct {
|
||||||
Platforms []Platform
|
Platforms []Platform
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,6 @@ import (
|
||||||
"golang.org/x/sync/errgroup"
|
"golang.org/x/sync/errgroup"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
|
|
||||||
)
|
|
||||||
|
|
||||||
type WriterOpt struct {
|
type WriterOpt struct {
|
||||||
Snapshotter snapshot.Snapshotter
|
Snapshotter snapshot.Snapshotter
|
||||||
ContentStore content.Store
|
ContentStore content.Store
|
||||||
|
@ -413,7 +409,7 @@ func normalizeLayersAndHistory(remote *solver.Remote, history []ocispec.History,
|
||||||
var layerIndex int
|
var layerIndex int
|
||||||
for i, h := range history {
|
for i, h := range history {
|
||||||
if !h.EmptyLayer {
|
if !h.EmptyLayer {
|
||||||
if remote.Descriptors[layerIndex].Digest == emptyGZLayer {
|
if remote.Descriptors[layerIndex].Digest == exptypes.EmptyGZLayer {
|
||||||
h.EmptyLayer = true
|
h.EmptyLayer = true
|
||||||
remote.Descriptors = append(remote.Descriptors[:layerIndex], remote.Descriptors[layerIndex+1:]...)
|
remote.Descriptors = append(remote.Descriptors[:layerIndex], remote.Descriptors[layerIndex+1:]...)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -9,15 +9,12 @@ import (
|
||||||
"github.com/containerd/containerd/content"
|
"github.com/containerd/containerd/content"
|
||||||
"github.com/containerd/containerd/images"
|
"github.com/containerd/containerd/images"
|
||||||
"github.com/moby/buildkit/cache"
|
"github.com/moby/buildkit/cache"
|
||||||
|
"github.com/moby/buildkit/exporter/containerimage/exptypes"
|
||||||
digest "github.com/opencontainers/go-digest"
|
digest "github.com/opencontainers/go-digest"
|
||||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
emptyGZLayer = digest.Digest("sha256:4f4fb700ef54461cfa02571ae0db9a0dc1e0cdb5577484a6d75e68dc38e8acc1")
|
|
||||||
)
|
|
||||||
|
|
||||||
type Opt struct {
|
type Opt struct {
|
||||||
ImageStore images.Store
|
ImageStore images.Store
|
||||||
ContentStore content.Store
|
ContentStore content.Store
|
||||||
|
@ -93,7 +90,7 @@ func toDigests(layers []specs.Descriptor) []digest.Digest {
|
||||||
func layerKey(layers []digest.Digest) string {
|
func layerKey(layers []digest.Digest) string {
|
||||||
b := &strings.Builder{}
|
b := &strings.Builder{}
|
||||||
for _, l := range layers {
|
for _, l := range layers {
|
||||||
if l != emptyGZLayer {
|
if l != exptypes.EmptyGZLayer {
|
||||||
b.Write([]byte(l))
|
b.Write([]byte(l))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue