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:
commit
2447f67c52
1 changed files with 17 additions and 4 deletions
|
@ -321,7 +321,11 @@ func (p *puller) CacheKey(ctx context.Context, index int) (string, bool, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
if p.config != nil {
|
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 {
|
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 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) {
|
func (p *puller) Snapshot(ctx context.Context) (cache.ImmutableRef, error) {
|
||||||
|
@ -776,8 +789,8 @@ func cacheKeyFromConfig(dt []byte) digest.Digest {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return digest.FromBytes(dt)
|
return digest.FromBytes(dt)
|
||||||
}
|
}
|
||||||
if img.RootFS.Type != "layers" {
|
if img.RootFS.Type != "layers" || len(img.RootFS.DiffIDs) == 0 {
|
||||||
return digest.FromBytes(dt)
|
return ""
|
||||||
}
|
}
|
||||||
return identity.ChainID(img.RootFS.DiffIDs)
|
return identity.ChainID(img.RootFS.DiffIDs)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue