@@ -12,9 +12,6 @@ import (
12
12
"time"
13
13
14
14
"github.com/gitpod-io/leeway/pkg/leeway"
15
- "github.com/gitpod-io/leeway/pkg/leeway/cache"
16
- "github.com/gitpod-io/leeway/pkg/leeway/cache/local"
17
- "github.com/gitpod-io/leeway/pkg/leeway/cache/remote"
18
15
"github.com/gookit/color"
19
16
log "github.com/sirupsen/logrus"
20
17
"github.com/spf13/cobra"
@@ -87,7 +84,7 @@ var buildCmd = &cobra.Command{
87
84
},
88
85
}
89
86
90
- func serveBuildResult (ctx context.Context , addr string , localCache cache. LocalCache , pkg * leeway.Package ) {
87
+ func serveBuildResult (ctx context.Context , addr string , localCache * leeway. FilesystemCache , pkg * leeway.Package ) {
91
88
br , exists := localCache .Location (pkg )
92
89
if ! exists {
93
90
log .Fatal ("build result is not in local cache despite just being built. Something's wrong with the cache." )
@@ -124,7 +121,7 @@ func serveBuildResult(ctx context.Context, addr string, localCache cache.LocalCa
124
121
}
125
122
}
126
123
127
- func saveBuildResult (ctx context.Context , loc string , localCache cache. LocalCache , pkg * leeway.Package ) {
124
+ func saveBuildResult (ctx context.Context , loc string , localCache * leeway. FilesystemCache , pkg * leeway.Package ) {
128
125
br , exists := localCache .Location (pkg )
129
126
if ! exists {
130
127
log .Fatal ("build result is not in local cache despite just being built. Something's wrong with the cache." )
@@ -181,21 +178,20 @@ func addBuildFlags(cmd *cobra.Command) {
181
178
cmd .Flags ().Bool ("report-github" , os .Getenv ("GITHUB_OUTPUT" ) != "" , "Report package build success/failure to GitHub Actions using the GITHUB_OUTPUT environment variable" )
182
179
}
183
180
184
- func getBuildOpts (cmd * cobra.Command ) ([]leeway.BuildOption , cache. LocalCache ) {
181
+ func getBuildOpts (cmd * cobra.Command ) ([]leeway.BuildOption , * leeway. FilesystemCache ) {
185
182
cm , _ := cmd .Flags ().GetString ("cache" )
186
183
log .WithField ("cacheMode" , cm ).Debug ("configuring caches" )
187
184
cacheLevel := leeway .CacheLevel (cm )
188
185
189
- var remoteCache cache. RemoteCache
186
+ remoteCache := getRemoteCache ()
190
187
switch cacheLevel {
191
188
case leeway .CacheNone , leeway .CacheLocal :
192
- remoteCache = remote . NewNoRemoteCache ()
189
+ remoteCache = leeway. NoRemoteCache {}
193
190
case leeway .CacheRemotePull :
194
- remoteCache = & pullOnlyRemoteCache {C : remote . NewNoRemoteCache () }
191
+ remoteCache = & pullOnlyRemoteCache {C : remoteCache }
195
192
case leeway .CacheRemotePush :
196
- remoteCache = & pushOnlyRemoteCache {C : remote . NewNoRemoteCache () }
193
+ remoteCache = & pushOnlyRemoteCache {C : remoteCache }
197
194
case leeway .CacheRemote :
198
- remoteCache = remote .NewNoRemoteCache ()
199
195
default :
200
196
log .Fatalf ("invalid cache level: %s" , cacheLevel )
201
197
}
@@ -216,7 +212,7 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
216
212
}
217
213
}
218
214
log .WithField ("location" , localCacheLoc ).Debug ("set up local cache" )
219
- localCache , err := local .NewFilesystemCache (localCacheLoc )
215
+ localCache , err := leeway .NewFilesystemCache (localCacheLoc )
220
216
if err != nil {
221
217
log .Fatal (err )
222
218
}
@@ -314,33 +310,33 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
314
310
}
315
311
316
312
type pushOnlyRemoteCache struct {
317
- C cache .RemoteCache
313
+ C leeway .RemoteCache
318
314
}
319
315
320
- func (c * pushOnlyRemoteCache ) ExistingPackages (ctx context. Context , pkgs []cache .Package ) (map [cache .Package ]struct {}, error ) {
321
- return c .C .ExistingPackages (ctx , pkgs )
316
+ func (c * pushOnlyRemoteCache ) ExistingPackages (pkgs []* leeway .Package ) (map [* leeway .Package ]struct {}, error ) {
317
+ return c .C .ExistingPackages (pkgs )
322
318
}
323
319
324
- func (c * pushOnlyRemoteCache ) Download (ctx context. Context , dst cache. LocalCache , pkgs []cache .Package ) error {
320
+ func (c * pushOnlyRemoteCache ) Download (dst leeway. Cache , pkgs []* leeway .Package ) error {
325
321
return nil
326
322
}
327
323
328
- func (c * pushOnlyRemoteCache ) Upload (ctx context. Context , src cache. LocalCache , pkgs []cache .Package ) error {
329
- return c .C .Upload (ctx , src , pkgs )
324
+ func (c * pushOnlyRemoteCache ) Upload (src leeway. Cache , pkgs []* leeway .Package ) error {
325
+ return c .C .Upload (src , pkgs )
330
326
}
331
327
332
328
type pullOnlyRemoteCache struct {
333
- C cache .RemoteCache
329
+ C leeway .RemoteCache
334
330
}
335
331
336
- func (c * pullOnlyRemoteCache ) ExistingPackages (ctx context. Context , pkgs []cache .Package ) (map [cache .Package ]struct {}, error ) {
337
- return c .C .ExistingPackages (ctx , pkgs )
332
+ func (c * pullOnlyRemoteCache ) ExistingPackages (pkgs []* leeway .Package ) (map [* leeway .Package ]struct {}, error ) {
333
+ return c .C .ExistingPackages (pkgs )
338
334
}
339
335
340
- func (c * pullOnlyRemoteCache ) Download (ctx context. Context , dst cache. LocalCache , pkgs []cache .Package ) error {
341
- return c .C .Download (ctx , dst , pkgs )
336
+ func (c * pullOnlyRemoteCache ) Download (dst leeway. Cache , pkgs []* leeway .Package ) error {
337
+ return c .C .Download (dst , pkgs )
342
338
}
343
339
344
- func (c * pullOnlyRemoteCache ) Upload (ctx context. Context , src cache. LocalCache , pkgs []cache .Package ) error {
340
+ func (c * pullOnlyRemoteCache ) Upload (src leeway. Cache , pkgs []* leeway .Package ) error {
345
341
return nil
346
342
}
0 commit comments