remotecache: don’t export cache for empty layers

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
v0.8
Tonis Tiigi 2020-10-18 20:50:02 -07:00
parent 17b4ca1edf
commit 85dd12d875
1 changed files with 8 additions and 0 deletions

View File

@ -9,6 +9,10 @@ import (
"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 {
@ -238,6 +242,10 @@ 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 {
return parentID
}
state.descriptors[desc.Digest] = DescriptorProviderPair{ state.descriptors[desc.Digest] = DescriptorProviderPair{
Descriptor: desc, Descriptor: desc,
Provider: r.Provider, Provider: r.Provider,