Push pushes the specified source which must refer to an image in the local containers storage. It may or may not have the `containers-storage:` prefix. Use destination to push to a custom destination. The destination can refer to any supported transport. If not transport is specified, the docker
(ctx context.Context, source, destination string, options *PushOptions)
| 25 | // Return storage.ErrImageUnknown if source could not be found in the local |
| 26 | // containers storage. |
| 27 | func (r *Runtime) Push(ctx context.Context, source, destination string, options *PushOptions) ([]byte, error) { |
| 28 | if options == nil { |
| 29 | options = &PushOptions{} |
| 30 | } |
| 31 | |
| 32 | // Look up the local image. Note that we need to ignore the platform |
| 33 | // and push what the user specified (containers/podman/issues/10344). |
| 34 | image, resolvedSource, err := r.LookupImage(source, nil) |
| 35 | if err != nil { |
| 36 | return nil, err |
| 37 | } |
| 38 | |
| 39 | srcRef, err := image.StorageReference() |
| 40 | if err != nil { |
| 41 | return nil, err |
| 42 | } |
| 43 | |
| 44 | // Make sure we have a proper destination, and parse it into an image |
| 45 | // reference for copying. |
| 46 | if destination == "" { |
| 47 | // Doing an ID check here is tempting but false positives (due |
| 48 | // to a short partial IDs) are more painful than false |
| 49 | // negatives. |
| 50 | destination = resolvedSource |
| 51 | } |
| 52 | |
| 53 | logrus.Debugf("Pushing image %s to %s", source, destination) |
| 54 | |
| 55 | destRef, err := alltransports.ParseImageName(destination) |
| 56 | if err != nil { |
| 57 | // If the input does not include a transport assume it refers |
| 58 | // to a registry. |
| 59 | dockerRef, dockerErr := alltransports.ParseImageName("docker://" + destination) |
| 60 | if dockerErr != nil { |
| 61 | return nil, err |
| 62 | } |
| 63 | destRef = dockerRef |
| 64 | } |
| 65 | |
| 66 | if r.eventChannel != nil { |
| 67 | defer r.writeEvent(&Event{ID: image.ID(), Name: destination, Time: time.Now(), Type: EventTypeImagePush}) |
| 68 | } |
| 69 | |
| 70 | // Buildah compat: Make sure to tag the destination image if it's a |
| 71 | // Docker archive. This way, we preserve the image name. |
| 72 | if destRef.Transport().Name() == dockerArchiveTransport.Transport.Name() { |
| 73 | if named, err := reference.ParseNamed(resolvedSource); err == nil { |
| 74 | tagged, isTagged := named.(reference.NamedTagged) |
| 75 | if isTagged { |
| 76 | options.dockerArchiveAdditionalTags = []reference.NamedTagged{tagged} |
| 77 | } |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | c, err := r.newCopier(&options.CopyOptions) |
| 82 | if err != nil { |
| 83 | return nil, err |
| 84 | } |
nothing calls this directly
no test coverage detected