Skip to content

Commit 00e2165

Browse files
committed
limactl create: don't override user-specified name
Currently, when creating a new instance, the instance name specified by the user via `--name` gets discarded when a template is chosen later; the template name is used instead: $ ./_output/bin/limactl create --name test ? Creating an instance "test" Choose another template (docker, podman, archlinux, fedora, ...) ? Choose a template ubuntu-lts ? Creating an instance "ubuntu-lts" Proceed with the current configuration [output truncated...] INFO[0005] Run `limactl start ubuntu-lts` to start the instance. Fix that by only setting the instance name to the template name when it's not already set. After this change: $ ./_output/bin/limactl create --name test ? Creating an instance "test" Choose another template (docker, podman, archlinux, fedora, ...) ? Choose a template ubuntu-lts ? Creating an instance "test" Proceed with the current configuration [output truncated...] INFO[0005] Run `limactl start test` to start the instance. Signed-off-by: Ruoyu Zhong <[email protected]>
1 parent ce3b98a commit 00e2165

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

cmd/limactl/start.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -425,9 +425,11 @@ func chooseNextCreatorState(st *creatorState, yq string) (*creatorState, error)
425425
return st, fmt.Errorf("invalid answer %d for %d entries", ansEx, len(templates))
426426
}
427427
yamlPath := templates[ansEx].Location
428-
st.instName, err = guessarg.InstNameFromYAMLPath(yamlPath)
429-
if err != nil {
430-
return nil, err
428+
if st.instName == "" {
429+
st.instName, err = guessarg.InstNameFromYAMLPath(yamlPath)
430+
if err != nil {
431+
return nil, err
432+
}
431433
}
432434
st.yBytes, err = os.ReadFile(yamlPath)
433435
if err != nil {

0 commit comments

Comments
 (0)