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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user