@@ -18,6 +18,7 @@ import (
18
18
"time"
19
19
20
20
"github.com/coreos/go-semver/semver"
21
+ "github.com/lima-vm/lima/pkg/cacheutil"
21
22
"github.com/lima-vm/lima/pkg/driver"
22
23
"github.com/lima-vm/lima/pkg/driverutil"
23
24
"github.com/lima-vm/lima/pkg/executil"
@@ -26,8 +27,6 @@ import (
26
27
"github.com/lima-vm/lima/pkg/qemu/entitlementutil"
27
28
"github.com/mattn/go-isatty"
28
29
29
- "github.com/lima-vm/lima/pkg/downloader"
30
- "github.com/lima-vm/lima/pkg/fileutils"
31
30
hostagentevents "github.com/lima-vm/lima/pkg/hostagent/events"
32
31
"github.com/lima-vm/lima/pkg/limayaml"
33
32
"github.com/lima-vm/lima/pkg/store"
@@ -39,41 +38,6 @@ import (
39
38
// to be running before timing out.
40
39
const DefaultWatchHostAgentEventsTimeout = 10 * time .Minute
41
40
42
- // ensureNerdctlArchiveCache prefetches the nerdctl-full-VERSION-GOOS-GOARCH.tar.gz archive
43
- // into the cache before launching the hostagent process, so that we can show the progress in tty.
44
- // https://github.com/lima-vm/lima/issues/326
45
- func ensureNerdctlArchiveCache (ctx context.Context , y * limayaml.LimaYAML , created bool ) (string , error ) {
46
- if ! * y .Containerd .System && ! * y .Containerd .User {
47
- // nerdctl archive is not needed
48
- return "" , nil
49
- }
50
-
51
- errs := make ([]error , len (y .Containerd .Archives ))
52
- for i , f := range y .Containerd .Archives {
53
- // Skip downloading again if the file is already in the cache
54
- if created && f .Arch == * y .Arch && ! downloader .IsLocal (f .Location ) {
55
- path , err := fileutils .CachedFile (f )
56
- if err == nil {
57
- return path , nil
58
- }
59
- }
60
- path , err := fileutils .DownloadFile (ctx , "" , f , false , "the nerdctl archive" , * y .Arch )
61
- if err != nil {
62
- errs [i ] = err
63
- continue
64
- }
65
- if path == "" {
66
- if downloader .IsLocal (f .Location ) {
67
- return f .Location , nil
68
- }
69
- return "" , fmt .Errorf ("cache did not contain %q" , f .Location )
70
- }
71
- return path , nil
72
- }
73
-
74
- return "" , fileutils .Errors (errs )
75
- }
76
-
77
41
type Prepared struct {
78
42
Driver driver.Driver
79
43
NerdctlArchiveCache string
@@ -101,7 +65,7 @@ func Prepare(ctx context.Context, inst *store.Instance) (*Prepared, error) {
101
65
if err := limaDriver .CreateDisk (ctx ); err != nil {
102
66
return nil , err
103
67
}
104
- nerdctlArchiveCache , err := ensureNerdctlArchiveCache (ctx , inst .Config , created )
68
+ nerdctlArchiveCache , err := cacheutil . EnsureNerdctlArchiveCache (ctx , inst .Config , created )
105
69
if err != nil {
106
70
return nil , err
107
71
}
0 commit comments