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