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