From 46d0e828650d58b31125e6459122eea034ccd22e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20F=20Bj=C3=B6rklund?= Date: Sun, 13 Aug 2023 18:15:04 +0200 Subject: [PATCH] Validate arch against image not default MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Anders F Björklund --- examples/experimental/riscv64.yaml | 2 ++ pkg/limayaml/validate.go | 8 ++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/experimental/riscv64.yaml b/examples/experimental/riscv64.yaml index 636b58e5459..f71e978a887 100644 --- a/examples/experimental/riscv64.yaml +++ b/examples/experimental/riscv64.yaml @@ -3,6 +3,7 @@ arch: "riscv64" images: - location: "https://cloud-images.ubuntu.com/releases/23.04/release-20230810/ubuntu-23.04-server-cloudimg-riscv64.img" + arch: "riscv64" digest: "sha256:d9f56eac9c644f78353154d9f17e1ce739d7c63beac63ccefe2380b2f2e9aa38" kernel: # Extracted from http://http.us.debian.org/debian/pool/main/u/u-boot/u-boot-qemu_2023.01+dfsg-2_all.deb (GPL-2.0) @@ -11,6 +12,7 @@ images: # Fallback to the latest release image. # Hint: run `limactl prune` to invalidate the cache - location: "https://cloud-images.ubuntu.com/releases/23.04/release/ubuntu-23.04-server-cloudimg-riscv64.img" + arch: "riscv64" kernel: # Extracted from http://http.us.debian.org/debian/pool/main/u/u-boot/u-boot-qemu_2023.04+dfsg-1_all.deb (GPL-2.0) location: "https://github.com/lima-vm/u-boot-qemu-mirror/releases/download/2023.04%2Bdfsg-1/qemu-riscv64_smode_uboot.elf" diff --git a/pkg/limayaml/validate.go b/pkg/limayaml/validate.go index 47a93520257..7495216d38a 100644 --- a/pkg/limayaml/validate.go +++ b/pkg/limayaml/validate.go @@ -75,8 +75,8 @@ func Validate(y LimaYAML, warn bool) error { if err := validateFileObject(f.Kernel.File, fmt.Sprintf("images[%d].kernel", i)); err != nil { return err } - if f.Kernel.Arch != *y.Arch { - return fmt.Errorf("images[%d].kernel has unexpected architecture %q, must be %q", i, f.Kernel.Arch, *y.Arch) + if f.Kernel.Arch != f.Arch { + return fmt.Errorf("images[%d].kernel has unexpected architecture %q, must be %q", i, f.Kernel.Arch, f.Arch) } } else if f.Arch == RISCV64 { return errors.New("riscv64 needs the kernel (e.g., \"uboot.elf\") to be specified") @@ -88,8 +88,8 @@ func Validate(y LimaYAML, warn bool) error { if f.Kernel == nil { return errors.New("initrd requires the kernel to be specified") } - if f.Initrd.Arch != *y.Arch { - return fmt.Errorf("images[%d].initrd has unexpected architecture %q, must be %q", i, f.Initrd.Arch, *y.Arch) + if f.Initrd.Arch != f.Arch { + return fmt.Errorf("images[%d].initrd has unexpected architecture %q, must be %q", i, f.Initrd.Arch, f.Arch) } } }