loadMultiImageDockerArchive loads the docker archive specified by ref. In case the path@reference notation was used, only the specifiec image will be loaded. Otherwise, all images will be loaded.
(ctx context.Context, ref types.ImageReference, options *CopyOptions)
| 100 | // case the path@reference notation was used, only the specifiec image will be |
| 101 | // loaded. Otherwise, all images will be loaded. |
| 102 | func (r *Runtime) loadMultiImageDockerArchive(ctx context.Context, ref types.ImageReference, options *CopyOptions) ([]string, error) { |
| 103 | // If we cannot stat the path, it either does not exist OR the correct |
| 104 | // syntax to reference an image within the archive was used, so we |
| 105 | // should. |
| 106 | path := ref.StringWithinTransport() |
| 107 | if _, err := os.Stat(path); err != nil { |
| 108 | return r.copyFromDockerArchive(ctx, ref, options) |
| 109 | } |
| 110 | |
| 111 | reader, err := dockerArchiveTransport.NewReader(r.systemContextCopy(), path) |
| 112 | if err != nil { |
| 113 | return nil, err |
| 114 | } |
| 115 | |
| 116 | refLists, err := reader.List() |
| 117 | if err != nil { |
| 118 | return nil, err |
| 119 | } |
| 120 | |
| 121 | var copiedImages []string |
| 122 | for _, list := range refLists { |
| 123 | for _, listRef := range list { |
| 124 | names, err := r.copyFromDockerArchiveReaderReference(ctx, reader, listRef, options) |
| 125 | if err != nil { |
| 126 | return nil, err |
| 127 | } |
| 128 | copiedImages = append(copiedImages, names...) |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | return copiedImages, nil |
| 133 | } |
no test coverage detected