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 <transport>:<path>
it should be valid and succeed.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #782
Approved by: rhatdan
This commit is contained in:
umohnani8
2018-05-16 11:41:08 -04:00
committed by Atomic Bot
parent 5c54c53534
commit 7dced311d1
4 changed files with 34 additions and 8 deletions

View File

@ -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
}