imageReferenceMatchesContext return true if the specified reference matches the platform (os, arch, variant) as specified by the lookup options.
(ref types.ImageReference, options *LookupImageOptions)
| 481 | // imageReferenceMatchesContext return true if the specified reference matches |
| 482 | // the platform (os, arch, variant) as specified by the lookup options. |
| 483 | func (r *Runtime) imageReferenceMatchesContext(ref types.ImageReference, options *LookupImageOptions) (bool, error) { |
| 484 | if options.Architecture+options.OS+options.Variant == "" { |
| 485 | return true, nil |
| 486 | } |
| 487 | |
| 488 | ctx := context.Background() |
| 489 | img, err := ref.NewImage(ctx, &r.systemContext) |
| 490 | if err != nil { |
| 491 | return false, err |
| 492 | } |
| 493 | defer img.Close() |
| 494 | data, err := img.Inspect(ctx) |
| 495 | if err != nil { |
| 496 | return false, err |
| 497 | } |
| 498 | |
| 499 | if options.Architecture != "" && options.Architecture != data.Architecture { |
| 500 | logrus.Debugf("architecture %q does not match architecture %q of image %s", options.Architecture, data.Architecture, ref) |
| 501 | return false, nil |
| 502 | } |
| 503 | if options.OS != "" && options.OS != data.Os { |
| 504 | logrus.Debugf("OS %q does not match OS %q of image %s", options.OS, data.Os, ref) |
| 505 | return false, nil |
| 506 | } |
| 507 | if options.Variant != "" && options.Variant != data.Variant { |
| 508 | logrus.Debugf("variant %q does not match variant %q of image %s", options.Variant, data.Variant, ref) |
| 509 | return false, nil |
| 510 | } |
| 511 | |
| 512 | return true, nil |
| 513 | } |
| 514 | |
| 515 | // IsExternalContainerFunc allows for checking whether the specified container |
| 516 | // is an external one. The definition of an external container can be set by |
no test coverage detected