Skip to content

Commit 6642aaa

Browse files
committed
Return error early when instance already exists
Without the additional check, we would offer the user to edit the template, and only then throw an error that the instance already exists. Fixes #2575 Signed-off-by: Jan Dubois <[email protected]>
1 parent e6babd6 commit 6642aaa

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

cmd/limactl/start.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
149149
if err != nil {
150150
return nil, err
151151
}
152-
if len(tmpl.Bytes) == 0 {
152+
if len(tmpl.Bytes) > 0 {
153+
if createOnly {
154+
if _, err := store.Inspect(tmpl.Name); err == nil {
155+
return nil, fmt.Errorf("instance %q already exists", tmpl.Name)
156+
}
157+
}
158+
} else {
153159
if arg == "" {
154160
if tmpl.Name == "" {
155161
tmpl.Name = DefaultInstanceName

0 commit comments

Comments
 (0)