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