support specifying a non-latest tag using --import-cache type=local
https://github.com/moby/buildkit/issues/1242 Signed-off-by: Tomohiro Kusumoto <zabio1192@gmail.com>v0.7
parent
f7cf4823f7
commit
807b20346e
|
@ -357,6 +357,7 @@ The directory layout conforms to OCI Image Spec v1.0.
|
|||
- `ref=docker.io/user/image:tag`: reference for `registry` cache importer
|
||||
- `src=path/to/input-dir`: directory for `local` cache importer
|
||||
- `digest=sha256:deadbeef`: digest of the manifest list to import for `local` cache importer.
|
||||
- `tag=customtag`: custom tag of image for `local` cache importer.
|
||||
Defaults to the digest of "latest" tag in `index.json`
|
||||
|
||||
### Consistent hashing
|
||||
|
|
|
@ -423,13 +423,13 @@ func parseCacheOptions(opt SolveOpt) (*cacheOptions, error) {
|
|||
continue
|
||||
}
|
||||
for _, m := range idx.Manifests {
|
||||
if m.Annotations[ocispec.AnnotationRefName] == "latest" {
|
||||
if (m.Annotations[ocispec.AnnotationRefName] == "latest" && attrs["tag"] == "") || (attrs["tag"] != "" && m.Annotations[ocispec.AnnotationRefName] == attrs["tag"]) {
|
||||
attrs["digest"] = string(m.Digest)
|
||||
break
|
||||
}
|
||||
}
|
||||
if attrs["digest"] == "" {
|
||||
return nil, errors.New("local cache importer requires either explicit digest or \"latest\" tag on index.json")
|
||||
return nil, errors.New("local cache importer requires either explicit digest, \"latest\" tag or custom tag on index.json")
|
||||
}
|
||||
}
|
||||
contentStores["local:"+csDir] = cs
|
||||
|
|
Loading…
Reference in New Issue