Expand image refs and handle refs with digests
If an image that we're pulling from a registry has a digest in its reference, use that to construct the destination image's reference. This should help us detect cases where the image has previously been pulled. When we have a filter to use when listing images, expand it into a reference so that we can properly match against names of images that we've previously stored using fully expanded references. Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
This commit is contained in:
parent
3d15bc571b
commit
a0b1da15a3
2 changed files with 51 additions and 1 deletions
|
@ -43,7 +43,19 @@ type ImageServer interface {
|
|||
func (svc *imageService) ListImages(filter string) ([]ImageResult, error) {
|
||||
results := []ImageResult{}
|
||||
if filter != "" {
|
||||
if image, err := svc.store.GetImage(filter); err == nil {
|
||||
ref, err := alltransports.ParseImageName(filter)
|
||||
if err != nil {
|
||||
ref2, err2 := istorage.Transport.ParseStoreReference(svc.store, "@"+filter)
|
||||
if err2 != nil {
|
||||
ref3, err3 := istorage.Transport.ParseStoreReference(svc.store, filter)
|
||||
if err3 != nil {
|
||||
return nil, err
|
||||
}
|
||||
ref2 = ref3
|
||||
}
|
||||
ref = ref2
|
||||
}
|
||||
if image, err := istorage.Transport.GetStoreImage(svc.store, ref); err == nil {
|
||||
results = append(results, ImageResult{
|
||||
ID: image.ID,
|
||||
Names: image.Names,
|
||||
|
@ -136,6 +148,9 @@ func (svc *imageService) PullImage(systemContext *types.SystemContext, imageName
|
|||
if tagged, ok := srcRef.DockerReference().(reference.NamedTagged); ok {
|
||||
dest = dest + ":" + tagged.Tag()
|
||||
}
|
||||
if canonical, ok := srcRef.DockerReference().(reference.Canonical); ok {
|
||||
dest = dest + "@" + canonical.Digest().String()
|
||||
}
|
||||
}
|
||||
destRef, err := istorage.Transport.ParseStoreReference(svc.store, dest)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue