go-containerregistry
go-containerregistry copied to clipboard
feat: allow pushing an image by digest
When there are multiple images in the OCI directory the user can select the one you want by digest specifying it in the image reference (destination string).
Testing
Pull down some sample images. The first is a manifest.list and the second third is a plain manifest.
crane pull --format oci quay.io/csiaddons/volumereplication-operator:v0.3.0 saved.oci
crane pull --format oci quay.io/ceph/ceph-amd64:v17.2.1-20220623 saved.oci
podman run -d -p 127.0.0.1:5000:5000 --name registry docker.io/library/registry:2
go run ./cmd/crane push --index --insecure saved.oci localhost:5000/volumereplication-operator@sha256:cba18d9c2cd17f52fc4f1b8d19a3f6af18d29b7aded5ed0f21388da87fd6f543
go run ./cmd/crane push --index --insecure saved.oci localhost:5000/ceph-amd64@sha256:b4e95ad6b1a4fb02b3d5c3fc8cbdb91431d03fdf5c6d904f8a5cf1efb4053f27
podman rm -f registry
The current alternative for the user is to modify saved.oci/index.json to contain a single manifest descriptor of the image they want to push. This can be done with jq but is rather tedious.