Skip to content

feat(template): support template-less image variant selection#5159

Open
Nachiket-Roy wants to merge 1 commit into
lima-vm:masterfrom
Nachiket-Roy:image-variant
Open

feat(template): support template-less image variant selection#5159
Nachiket-Roy wants to merge 1 commit into
lima-vm:masterfrom
Nachiket-Roy:image-variant

Conversation

@Nachiket-Roy

@Nachiket-Roy Nachiket-Roy commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Description

This PR adds support for image variants (for example, Ubuntu Minimal or Debian NoCloud) without introducing additional template files such as ubuntu-minimal.yaml or debian-nocloud.yaml.

A new variant field is added to image entries, allowing users to select specific image variants dynamically with the existing --set flag.

To preserve the current behavior, standard/server images are listed before minimal variants, ensuring that default template usage continues to select standard images.

How to use

Start Ubuntu 24.04 Minimal:

llimactl start --image-variant=minimal template:ubuntu-24.04

Start Debian 12 NoCloud:

limactl start --image-variant=nocloud template:debian-12

Tests

Added TestDefaultSelectedImageIsStandard to verify that standard images remain the default selection by ensuring they are ordered before minimal variants.

Fixes #5153
Fixes #5158

@Nachiket-Roy Nachiket-Roy force-pushed the image-variant branch 2 times, most recently from 4acd3b1 to 282433b Compare June 27, 2026 08:41
@AkihiroSuda

Copy link
Copy Markdown
Member

--set '.images = [.images[] | select(.variant == "minimal")]' \

There should be --image-variant=STRING in

func RegisterCreate(cmd *cobra.Command, commentPrefix string) {

Comment thread templates/_images/ubuntu-26.04.yaml
Comment thread cmd/limactl/editflags/editflags.go Outdated
Comment thread pkg/driver/vz/vz_driver_darwin.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for selecting OS image “variants” (e.g., Ubuntu minimal, Debian nocloud) without multiplying template files, by tagging image entries with a variant and enabling CLI-based filtering while preserving existing default image selection behavior.

Changes:

  • Add variant to limatype.Image and propagate acceptance of the field through driver config validation.
  • Introduce --image-variant flag (implemented via yq expression) to select a specific image variant at instance creation.
  • Update Ubuntu/Debian image catalogs to include variant-tagged entries and add tests to validate unmarshalling and default ordering.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
templates/_images/ubuntu-26.04.yaml Adds variant: server entries and introduces minimal variant images (with fallback).
templates/_images/ubuntu-24.04.yaml Adds variant: server entries and introduces minimal variant images (with fallback).
templates/_images/ubuntu-22.04.yaml Adds variant: server entries and introduces minimal variant images (amd64).
templates/_images/debian-13.yaml Tags existing images as genericcloud/generic and adds nocloud variant images (with fallback).
templates/_images/debian-12.yaml Tags existing images as genericcloud/generic and adds nocloud variant images (with fallback).
pkg/limayaml/defaults_test.go Adds tests for variant unmarshalling and default image ordering in templates.
pkg/limatype/lima_yaml.go Extends Image type to include Variant.
pkg/instance/start.go Enforces “stick to the first variant for the target arch” during image download attempts.
pkg/driver/wsl2/wsl_driver_windows.go Allows Variant in WSL2 image validation/unknown-field filtering.
pkg/driver/vz/vz_driver_darwin.go Allows Variant in VZ image validation/unknown-field filtering.
cmd/limactl/editflags/editflags.go Adds --image-variant flag and generates yq to filter .images by variant.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/instance/start.go
Comment thread cmd/limactl/editflags/editflags.go
Comment thread pkg/limayaml/defaults_test.go Outdated
…g instance start

Signed-off-by: Nachiket Roy <nachiket.roy.2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generic variant tag for image entries Create support for the ubuntu-minimal images

3 participants