Load loads one or more images (depending on the transport) from the specified path. The path may point to an image the following transports: oci, oci-archive, dir, docker-archive.
(ctx context.Context, path string, options *LoadOptions)
| 22 | // specified path. The path may point to an image the following transports: |
| 23 | // oci, oci-archive, dir, docker-archive. |
| 24 | func (r *Runtime) Load(ctx context.Context, path string, options *LoadOptions) ([]string, error) { |
| 25 | logrus.Debugf("Loading image from %q", path) |
| 26 | |
| 27 | if r.eventChannel != nil { |
| 28 | defer r.writeEvent(&Event{ID: "", Name: path, Time: time.Now(), Type: EventTypeImageLoad}) |
| 29 | } |
| 30 | |
| 31 | if options == nil { |
| 32 | options = &LoadOptions{} |
| 33 | } |
| 34 | |
| 35 | var loadErrors []error |
| 36 | |
| 37 | for _, f := range []func() ([]string, string, error){ |
| 38 | // OCI |
| 39 | func() ([]string, string, error) { |
| 40 | logrus.Debugf("-> Attempting to load %q as an OCI directory", path) |
| 41 | ref, err := ociTransport.NewReference(path, "") |
| 42 | if err != nil { |
| 43 | return nil, ociTransport.Transport.Name(), err |
| 44 | } |
| 45 | images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions) |
| 46 | return images, ociTransport.Transport.Name(), err |
| 47 | }, |
| 48 | |
| 49 | // OCI-ARCHIVE |
| 50 | func() ([]string, string, error) { |
| 51 | logrus.Debugf("-> Attempting to load %q as an OCI archive", path) |
| 52 | ref, err := ociArchiveTransport.NewReference(path, "") |
| 53 | if err != nil { |
| 54 | return nil, ociArchiveTransport.Transport.Name(), err |
| 55 | } |
| 56 | images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions) |
| 57 | return images, ociArchiveTransport.Transport.Name(), err |
| 58 | }, |
| 59 | |
| 60 | // DOCKER-ARCHIVE |
| 61 | func() ([]string, string, error) { |
| 62 | logrus.Debugf("-> Attempting to load %q as a Docker archive", path) |
| 63 | ref, err := dockerArchiveTransport.ParseReference(path) |
| 64 | if err != nil { |
| 65 | return nil, dockerArchiveTransport.Transport.Name(), err |
| 66 | } |
| 67 | images, err := r.loadMultiImageDockerArchive(ctx, ref, &options.CopyOptions) |
| 68 | return images, dockerArchiveTransport.Transport.Name(), err |
| 69 | }, |
| 70 | |
| 71 | // DIR |
| 72 | func() ([]string, string, error) { |
| 73 | logrus.Debugf("-> Attempting to load %q as a Docker dir", path) |
| 74 | ref, err := dirTransport.NewReference(path) |
| 75 | if err != nil { |
| 76 | return nil, dirTransport.Transport.Name(), err |
| 77 | } |
| 78 | images, err := r.copyFromDefault(ctx, ref, &options.CopyOptions) |
| 79 | return images, dirTransport.Transport.Name(), err |
| 80 | }, |
| 81 | } { |