Skip to content

Commit c8dd6b1

Browse files
authored
Merge pull request #3977 from unsuman/fix/prune
Fix: prune by warning off driver validation error
2 parents 8f0bc98 + ce4edc6 commit c8dd6b1

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

cmd/limactl/prune.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ package main
55

66
import (
77
"context"
8-
"fmt"
98
"maps"
109
"os"
1110

@@ -80,6 +79,10 @@ func knownLocations(ctx context.Context) (map[string]limatype.File, error) {
8079
if err != nil {
8180
return nil, err
8281
}
82+
if instance.Errors != nil {
83+
logrus.Warnf("skipping instance %q because it has errors: %v", instanceName, instance.Errors)
84+
continue
85+
}
8386
maps.Copy(locations, locationsFromLimaYAML(instance.Config))
8487
}
8588

@@ -98,7 +101,8 @@ func knownLocations(ctx context.Context) (map[string]limatype.File, error) {
98101
return nil, err
99102
}
100103
if err := driverutil.ResolveVMType(ctx, y, t.Name); err != nil {
101-
return nil, fmt.Errorf("failed to resolve vm for %q: %w", t.Name, err)
104+
logrus.Warnf("failed to resolve vm for %q: %v", t.Name, err)
105+
continue
102106
}
103107
maps.Copy(locations, locationsFromLimaYAML(y))
104108
}

cmd/limactl/template.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ func templateValidateAction(cmd *cobra.Command, args []string) error {
264264
}
265265
if err := driverutil.ResolveVMType(ctx, y, filePath); err != nil {
266266
logrus.Warnf("failed to resolve VM type for %q: %v", filePath, err)
267-
return nil
267+
continue
268268
}
269269
if err := limayaml.Validate(y, false); err != nil {
270270
return fmt.Errorf("failed to validate YAML file %q: %w", arg, err)

pkg/driverutil/vm.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ import (
1717
"github.com/lima-vm/lima/v2/pkg/registry"
1818
)
1919

20+
// ResolveVMType sets the VMType field in the given LimaYAML if not already set.
21+
// It validates the configuration against the specified or default VMType.
2022
func ResolveVMType(ctx context.Context, y *limatype.LimaYAML, filePath string) error {
2123
if y.VMType != nil && *y.VMType != "" {
2224
if err := validateConfigAgainstDriver(ctx, y, filePath, *y.VMType); err != nil {

0 commit comments

Comments
 (0)