1
0
mirror of https://github.com/lxc/incus.git synced 2026-02-05 09:46:19 +01:00

client/oci: Allow OCI image names with a pinned hash

Enables specifying OCI images as `IMAGE:TAG@HASH`

Signed-off-by: Angelos Kolaitis <neoaggelos@gmail.com>
This commit is contained in:
Angelos Kolaitis
2025-09-06 20:58:54 +03:00
parent bf93150a14
commit a0aad161fc

View File

@@ -395,6 +395,13 @@ func (r *ProtocolOCI) runSkopeo(action string, image string, args ...string) (st
// GetImageAlias returns an existing alias as an ImageAliasesEntry struct.
func (r *ProtocolOCI) GetImageAlias(name string) (*api.ImageAliasesEntry, string, error) {
// If image name is "IMAGE:TAG@HASH", drop ":TAG" so that skopeo uses the pinned hash instead.
imageWithoutHash, hash, hasHash := strings.Cut(name, "@")
if hasHash {
imageWithoutTag, _, _ := strings.Cut(imageWithoutHash, ":")
name = fmt.Sprintf("%s@%s", imageWithoutTag, hash)
}
// Get the image information from skopeo.
stdout, err := r.runSkopeo("inspect", name)
if err != nil {