1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #38897 from tonistiigi/schema1-fix

builder-next: fix second cachekey for schema1
This commit is contained in:
Derek McGowan 2019-03-21 10:59:32 -07:00 committed by GitHub
commit 2447f67c52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -321,7 +321,11 @@ func (p *puller) CacheKey(ctx context.Context, index int) (string, bool, error)
}
if p.config != nil {
return cacheKeyFromConfig(p.config).String(), true, nil
k := cacheKeyFromConfig(p.config).String()
if k == "" {
return digest.FromBytes(p.config).String(), true, nil
}
return k, true, nil
}
if err := p.resolve(ctx); err != nil {
@ -336,7 +340,16 @@ func (p *puller) CacheKey(ctx context.Context, index int) (string, bool, error)
return dgst.String(), false, nil
}
return cacheKeyFromConfig(p.config).String(), true, nil
k := cacheKeyFromConfig(p.config).String()
if k == "" {
dgst, err := p.mainManifestKey(p.desc.Digest, p.platform)
if err != nil {
return "", false, err
}
return dgst.String(), true, nil
}
return k, true, nil
}
func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
@ -776,8 +789,8 @@ func cacheKeyFromConfig(dt []byte) digest.Digest {
if err != nil {
return digest.FromBytes(dt)
}
if img.RootFS.Type != "layers" {
return digest.FromBytes(dt)
if img.RootFS.Type != "layers" || len(img.RootFS.DiffIDs) == 0 {
return ""
}
return identity.ChainID(img.RootFS.DiffIDs)
}