Skip to content

fix: limactl create <image URL> honors --name flag#4628

Merged
jandubois merged 1 commit intolima-vm:masterfrom
Harry-kp:fix/create-ignores-name
Feb 24, 2026
Merged

fix: limactl create <image URL> honors --name flag#4628
jandubois merged 1 commit intolima-vm:masterfrom
Harry-kp:fix/create-ignores-name

Conversation

@Harry-kp
Copy link
Copy Markdown
Contributor

Summary

  • Fixes limactl create <HTTPS URL to an image> ignores --name #4626
  • imageTemplate() in pkg/limatmpl/locator.go unconditionally overwrote tmpl.Name with the name derived from the image URL, ignoring the --name CLI flag. Every other code path in Read() already guards the assignment with if tmpl.Name == "" — this PR applies the same guard to imageTemplate().

Reproduction

limactl create --name freebsd https://download.freebsd.org/releases/VM-IMAGES/15.0-RELEASE/aarch64/Latest/FreeBSD-15.0-RELEASE-arm64-aarch64-BASIC-CLOUDINIT-zfs.raw.xz

Before: instance created as freebsd-15.0-release-arm64-basic-zfs, ignoring --name freebsd
After: instance created as freebsd

Changes

  • pkg/limatmpl/locator.go: Guard tmpl.Name assignment in imageTemplate() with if tmpl.Name == ""
  • pkg/limatmpl/locator_test.go: Add TestReadImageURLRespectsName covering both the --name override and the default name derivation paths

Test plan

  • go test ./pkg/limatmpl/ -run TestReadImageURLRespectsName — passes
  • All existing TestInstNameFromImageURL tests — still pass

Copilot AI review requested due to automatic review settings February 24, 2026 20:03
@Harry-kp Harry-kp force-pushed the fix/create-ignores-name branch from 28151cc to 1f5af59 Compare February 24, 2026 20:04
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes limactl create <image URL> so an explicit --name is not overwritten by the image-URL-derived default name, aligning the image URL path with the other limatmpl.Read() locator handlers.

Changes:

  • Guard tmpl.Name assignment in imageTemplate() so it only derives a name when none was provided.
  • Add a regression test ensuring Read() respects an explicit name for image URLs and still derives a default when name is empty.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
pkg/limatmpl/locator.go Prevents image URL handling from overwriting a caller-provided instance name.
pkg/limatmpl/locator_test.go Adds coverage for both explicit-name override and default name derivation for image URLs.

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

`imageTemplate()` unconditionally overwrote `tmpl.Name` with the name
derived from the image URL, ignoring the `--name` flag passed via CLI.
Every other code path in `Read()` already guards the name assignment
with `if tmpl.Name == ""`. Apply the same guard in `imageTemplate()`.

Fixes lima-vm#4626

Signed-off-by: Harry-kp <chaudharyharshit9@gmail.com>
@Harry-kp Harry-kp force-pushed the fix/create-ignores-name branch from 1f5af59 to 8ee52e3 Compare February 24, 2026 20:07
Copy link
Copy Markdown
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

@jandubois jandubois added this to the v2.1.0 milestone Feb 24, 2026
@jandubois jandubois merged commit 85c1800 into lima-vm:master Feb 24, 2026
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants