imageIDsForManifest() parses the manifest of the copied image and then looks up the IDs of the matching image. There's a small slice of time, between when we copy the image into local storage and when we go to look for it using the name that we gave it when we copied it, when the name we wanted to
(manifestBytes []byte, sys *types.SystemContext)
| 394 | // assign to the image could have been moved, but the image's ID will remain |
| 395 | // the same until it is deleted. |
| 396 | func (r *Runtime) imagesIDsForManifest(manifestBytes []byte, sys *types.SystemContext) ([]string, error) { |
| 397 | var imageDigest digest.Digest |
| 398 | manifestType := manifest.GuessMIMEType(manifestBytes) |
| 399 | if manifest.MIMETypeIsMultiImage(manifestType) { |
| 400 | list, err := manifest.ListFromBlob(manifestBytes, manifestType) |
| 401 | if err != nil { |
| 402 | return nil, errors.Wrapf(err, "parsing manifest list") |
| 403 | } |
| 404 | d, err := list.ChooseInstance(sys) |
| 405 | if err != nil { |
| 406 | return nil, errors.Wrapf(err, "choosing instance from manifest list") |
| 407 | } |
| 408 | imageDigest = d |
| 409 | } else { |
| 410 | d, err := manifest.Digest(manifestBytes) |
| 411 | if err != nil { |
| 412 | return nil, errors.Wrapf(err, "digesting manifest") |
| 413 | } |
| 414 | imageDigest = d |
| 415 | } |
| 416 | var results []string |
| 417 | images, err := r.store.ImagesByDigest(imageDigest) |
| 418 | if err != nil { |
| 419 | return nil, errors.Wrapf(err, "listing images by manifest digest") |
| 420 | } |
| 421 | for _, image := range images { |
| 422 | results = append(results, image.ID) |
| 423 | } |
| 424 | if len(results) == 0 { |
| 425 | return nil, errors.Wrapf(storage.ErrImageUnknown, "identifying new image by manifest digest") |
| 426 | } |
| 427 | return results, nil |
| 428 | } |
| 429 | |
| 430 | // copySingleImageFromRegistry pulls the specified, possibly unqualified, name |
| 431 | // from a registry. On successful pull it returns the ID of the image in local |
no test coverage detected