Skip to content

Commit f52f307

Browse files
committed
fix tests: end dependence of registry in tests
Signed-off-by: Ansuman Sahoo <[email protected]>
1 parent 447b100 commit f52f307

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+214
-161
lines changed

cmd/limactl/clone.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ import (
1212
"github.com/spf13/cobra"
1313

1414
"github.com/lima-vm/lima/v2/cmd/limactl/editflags"
15+
"github.com/lima-vm/lima/v2/pkg/driverutil"
1516
"github.com/lima-vm/lima/v2/pkg/instance"
17+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
1618
"github.com/lima-vm/lima/v2/pkg/limayaml"
1719
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
1820
"github.com/lima-vm/lima/v2/pkg/store"
19-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
2021
"github.com/lima-vm/lima/v2/pkg/yqutil"
2122
)
2223

@@ -79,6 +80,9 @@ func cloneAction(cmd *cobra.Command, args []string) error {
7980
if err != nil {
8081
return err
8182
}
83+
if err := driverutil.ResolveVMType(y, filePath); err != nil {
84+
return fmt.Errorf("failed to accept config for %q: %w", filePath, err)
85+
}
8286
if err := limayaml.Validate(y, true); err != nil {
8387
return saveRejectedYAML(yBytes, err)
8488
}

cmd/limactl/disk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ import (
2020

2121
"github.com/lima-vm/lima/v2/pkg/imgutil/proxyimgutil"
2222
"github.com/lima-vm/lima/v2/pkg/limatype"
23+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
2324
"github.com/lima-vm/lima/v2/pkg/store"
24-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
2525
)
2626

2727
func newDiskCommand() *cobra.Command {

cmd/limactl/edit.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,15 @@ import (
1414
"github.com/spf13/cobra"
1515

1616
"github.com/lima-vm/lima/v2/cmd/limactl/editflags"
17+
"github.com/lima-vm/lima/v2/pkg/driverutil"
1718
"github.com/lima-vm/lima/v2/pkg/editutil"
1819
"github.com/lima-vm/lima/v2/pkg/instance"
1920
"github.com/lima-vm/lima/v2/pkg/limatype"
21+
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
22+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
2023
"github.com/lima-vm/lima/v2/pkg/limayaml"
2124
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
2225
"github.com/lima-vm/lima/v2/pkg/store"
23-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
2426
"github.com/lima-vm/lima/v2/pkg/uiutil"
2527
"github.com/lima-vm/lima/v2/pkg/yqutil"
2628
)
@@ -51,7 +53,7 @@ func editAction(cmd *cobra.Command, args []string) error {
5153
if arg == "" {
5254
arg = DefaultInstanceName
5355
}
54-
if err := store.ValidateInstName(arg); err == nil {
56+
if err := dirnames.ValidateInstName(arg); err == nil {
5557
inst, err = store.Inspect(arg)
5658
if err != nil {
5759
if errors.Is(err, os.ErrNotExist) {
@@ -122,6 +124,9 @@ func editAction(cmd *cobra.Command, args []string) error {
122124
if err != nil {
123125
return err
124126
}
127+
if err := driverutil.ResolveVMType(y, filePath); err != nil {
128+
return fmt.Errorf("failed to accept config for %q: %w", filePath, err)
129+
}
125130
if err := limayaml.Validate(y, true); err != nil {
126131
return saveRejectedYAML(yBytes, err)
127132
}

cmd/limactl/factory-reset.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import (
1414

1515
"github.com/lima-vm/lima/v2/pkg/cidata"
1616
"github.com/lima-vm/lima/v2/pkg/instance"
17+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
1718
"github.com/lima-vm/lima/v2/pkg/store"
18-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
1919
)
2020

2121
func newFactoryResetCommand() *cobra.Command {

cmd/limactl/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import (
1818
"github.com/lima-vm/lima/v2/pkg/debugutil"
1919
"github.com/lima-vm/lima/v2/pkg/driver/external/server"
2020
"github.com/lima-vm/lima/v2/pkg/fsutil"
21+
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
2122
"github.com/lima-vm/lima/v2/pkg/osutil"
22-
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
2323
"github.com/lima-vm/lima/v2/pkg/version"
2424
)
2525

cmd/limactl/prune.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
package main
55

66
import (
7+
"fmt"
78
"maps"
89
"os"
910

1011
"github.com/sirupsen/logrus"
1112
"github.com/spf13/cobra"
1213

1314
"github.com/lima-vm/lima/v2/pkg/downloader"
15+
"github.com/lima-vm/lima/v2/pkg/driverutil"
1416
"github.com/lima-vm/lima/v2/pkg/limatype"
1517
"github.com/lima-vm/lima/v2/pkg/limayaml"
1618
"github.com/lima-vm/lima/v2/pkg/store"
@@ -93,6 +95,9 @@ func knownLocations() (map[string]limatype.File, error) {
9395
if err != nil {
9496
return nil, err
9597
}
98+
if err := driverutil.ResolveVMType(y, t.Name); err != nil {
99+
return nil, fmt.Errorf("failed to accept config for %q: %w", t.Name, err)
100+
}
96101
maps.Copy(locations, locationsFromLimaYAML(y))
97102
}
98103
return locations, nil

cmd/limactl/show-ssh.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ import (
1313
"github.com/sirupsen/logrus"
1414
"github.com/spf13/cobra"
1515

16+
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
17+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
1618
"github.com/lima-vm/lima/v2/pkg/sshutil"
1719
"github.com/lima-vm/lima/v2/pkg/store"
18-
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
19-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
2020
)
2121

2222
const showSSHExample = `

cmd/limactl/start.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,17 @@ import (
1616
"github.com/spf13/cobra"
1717

1818
"github.com/lima-vm/lima/v2/cmd/limactl/editflags"
19+
"github.com/lima-vm/lima/v2/pkg/driverutil"
1920
"github.com/lima-vm/lima/v2/pkg/editutil"
2021
"github.com/lima-vm/lima/v2/pkg/instance"
2122
"github.com/lima-vm/lima/v2/pkg/limatmpl"
2223
"github.com/lima-vm/lima/v2/pkg/limatype"
24+
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
25+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
2326
"github.com/lima-vm/lima/v2/pkg/limayaml"
2427
networks "github.com/lima-vm/lima/v2/pkg/networks/reconcile"
2528
"github.com/lima-vm/lima/v2/pkg/registry"
2629
"github.com/lima-vm/lima/v2/pkg/store"
27-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
2830
"github.com/lima-vm/lima/v2/pkg/templatestore"
2931
"github.com/lima-vm/lima/v2/pkg/uiutil"
3032
"github.com/lima-vm/lima/v2/pkg/yqutil"
@@ -122,7 +124,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
122124
return nil, err
123125
}
124126
if name != "" {
125-
err := store.ValidateInstName(name)
127+
err := dirnames.ValidateInstName(name)
126128
if err != nil {
127129
return nil, err
128130
}
@@ -157,7 +159,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
157159
tty = false
158160
}
159161
var tmpl *limatmpl.Template
160-
if err := store.ValidateInstName(arg); arg == "" || err == nil {
162+
if err := dirnames.ValidateInstName(arg); arg == "" || err == nil {
161163
tmpl = &limatmpl.Template{Name: name}
162164
if arg == "" {
163165
if name == "" {
@@ -212,7 +214,7 @@ func loadOrCreateInstance(cmd *cobra.Command, args []string, createOnly bool) (*
212214
if _, err := store.Inspect(tmpl.Name); err == nil {
213215
return nil, fmt.Errorf("instance %q already exists", tmpl.Name)
214216
}
215-
} else if err := store.ValidateInstName(tmpl.Name); err != nil {
217+
} else if err := dirnames.ValidateInstName(tmpl.Name); err != nil {
216218
return nil, err
217219
}
218220
}
@@ -259,6 +261,9 @@ func applyYQExpressionToExistingInstance(inst *limatype.Instance, yq string) (*l
259261
if err != nil {
260262
return nil, err
261263
}
264+
if err := driverutil.ResolveVMType(y, filePath); err != nil {
265+
return nil, fmt.Errorf("failed to accept config for %q: %w", filePath, err)
266+
}
262267
if err := limayaml.Validate(y, true); err != nil {
263268
rejectedYAML := "lima.REJECTED.yaml"
264269
if writeErr := os.WriteFile(rejectedYAML, yBytes, 0o644); writeErr != nil {

cmd/limactl/template.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ import (
1212
"github.com/sirupsen/logrus"
1313
"github.com/spf13/cobra"
1414

15+
"github.com/lima-vm/lima/v2/pkg/driverutil"
1516
"github.com/lima-vm/lima/v2/pkg/limatmpl"
17+
"github.com/lima-vm/lima/v2/pkg/limatype/dirnames"
1618
"github.com/lima-vm/lima/v2/pkg/limayaml"
17-
"github.com/lima-vm/lima/v2/pkg/store/dirnames"
1819
"github.com/lima-vm/lima/v2/pkg/yqutil"
1920
)
2021

@@ -86,6 +87,9 @@ func fillDefaults(tmpl *limatmpl.Template) error {
8687
if err == nil {
8788
tmpl.Bytes, err = limayaml.Marshal(tmpl.Config, false)
8889
}
90+
if err := driverutil.ResolveVMType(tmpl.Config, filePath); err != nil {
91+
return fmt.Errorf("failed to accept config for %q: %w", filePath, err)
92+
}
8993
return err
9094
}
9195

@@ -242,6 +246,9 @@ func templateValidateAction(cmd *cobra.Command, args []string) error {
242246
if err != nil {
243247
return err
244248
}
249+
if err := driverutil.ResolveVMType(y, filePath); err != nil {
250+
return fmt.Errorf("failed to accept config for %q: %w", filePath, err)
251+
}
245252
if err := limayaml.Validate(y, false); err != nil {
246253
return fmt.Errorf("failed to validate YAML file %q: %w", arg, err)
247254
}

pkg/cidata/cidata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ import (
2626
"github.com/lima-vm/lima/v2/pkg/instance/hostname"
2727
"github.com/lima-vm/lima/v2/pkg/iso9660util"
2828
"github.com/lima-vm/lima/v2/pkg/limatype"
29+
"github.com/lima-vm/lima/v2/pkg/limatype/filenames"
2930
"github.com/lima-vm/lima/v2/pkg/limayaml"
3031
"github.com/lima-vm/lima/v2/pkg/localpathutil"
3132
"github.com/lima-vm/lima/v2/pkg/networks"
3233
"github.com/lima-vm/lima/v2/pkg/networks/usernet"
3334
"github.com/lima-vm/lima/v2/pkg/osutil"
3435
"github.com/lima-vm/lima/v2/pkg/sshutil"
35-
"github.com/lima-vm/lima/v2/pkg/store/filenames"
3636
)
3737

3838
var netLookupIP = func(host string) []net.IP {

0 commit comments

Comments
 (0)