allow skipping empty layer detection on cache export

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 29af1397e2)
Signed-off-by: Tibor Vass <tibor@docker.com>
v0.8
Tonis Tiigi 2021-02-24 01:11:17 -08:00 committed by Tibor Vass
parent edd0a756a3
commit 3a270318fc
1 changed files with 5 additions and 1 deletions

View File

@ -10,6 +10,10 @@ import (
"github.com/pkg/errors"
)
// EmptyLayerRemovalSupported defines if implementation supports removal of empty layers. Buildkit image exporter
// removes empty layers, but moby layerstore based implementation does not.
var EmptyLayerRemovalSupported = true
// sortConfig sorts the config structure to make sure it is deterministic
func sortConfig(cc *CacheConfig) {
type indexedLayer struct {
@ -239,7 +243,7 @@ func marshalRemote(r *solver.Remote, state *marshalState) string {
}
desc := r.Descriptors[len(r.Descriptors)-1]
if desc.Digest == exptypes.EmptyGZLayer {
if desc.Digest == exptypes.EmptyGZLayer && EmptyLayerRemovalSupported {
return parentID
}