From 7dced311d1119d98dbdd60f6d47fdde5abbff7d7 Mon Sep 17 00:00:00 2001 From: umohnani8 Date: Wed, 16 May 2018 11:41:08 -0400 Subject: Allow push/save without image reference If the user uses the image ID when saving to either docker-archive or oci-archive, then do not save a reference in the manifest/index.json. If the user chooses to push without an image reference, i.e : it should be valid and succeed. Signed-off-by: umohnani8 Closes: #782 Approved by: rhatdan --- libpod/image/pull.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libpod') diff --git a/libpod/image/pull.go b/libpod/image/pull.go index 2746d1bc5..38a8435de 100644 --- a/libpod/image/pull.go +++ b/libpod/image/pull.go @@ -123,10 +123,18 @@ func (ir *Runtime) getPullListFromRef(ctx context.Context, srcRef types.ImageRef return nil, errors.Wrapf(err, "error loading manifest for %q", srcRef) } + var dest string if manifest.Annotations == nil || manifest.Annotations["org.opencontainers.image.ref.name"] == "" { - return nil, errors.Errorf("error, archive doesn't have a name annotation. Cannot store image with no name") + // If the input image has no image.ref.name, we need to feed it a dest anyways + // use the hex of the digest + dest, err = getImageDigest(ctx, srcRef, sc) + if err != nil { + return nil, errors.Wrapf(err, "error getting image digest; image reference not found") + } + } else { + dest = manifest.Annotations["org.opencontainers.image.ref.name"] } - pullInfo, err := ir.getPullStruct(srcRef, manifest.Annotations["org.opencontainers.image.ref.name"]) + pullInfo, err := ir.getPullStruct(srcRef, dest) if err != nil { return nil, err } -- cgit v1.2.3-54-g00ecf