FindRoot find the root ResolvableDescriptor, representing an Image or Index, for a given imageName.
(imageName string)
| 50 | // FindRoot find the root ResolvableDescriptor, representing an Image or Index, for |
| 51 | // a given imageName. |
| 52 | func (p *Provider) FindRoot(imageName string) (ResolvableDescriptor, error) { |
| 53 | matcher := match.Name(imageName) |
| 54 | rootIndex, err := p.Index() |
| 55 | // of there is no root index, we are broken |
| 56 | if err != nil { |
| 57 | return nil, fmt.Errorf("invalid image cache: %v", err) |
| 58 | } |
| 59 | |
| 60 | // first try the root tag as an image itself |
| 61 | images, err := partial.FindImages(rootIndex, matcher) |
| 62 | if err == nil && len(images) > 0 { |
| 63 | // if we found the root tag as an image, just use it |
| 64 | return layoutImage{img: images[0]}, nil |
| 65 | } |
| 66 | // we did not find the root tag as an image, it is an index, get the index |
| 67 | indexes, err := partial.FindIndexes(rootIndex, matcher) |
| 68 | if err == nil && len(indexes) >= 1 { |
| 69 | return layoutIndex{idx: indexes[0]}, nil |
| 70 | } |
| 71 | return nil, fmt.Errorf("could not find image or index for %s", imageName) |
| 72 | } |
no test coverage detected