@@ -12,9 +12,6 @@ import (
1212 "time"
1313
1414 "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"
1815 "github.com/gookit/color"
1916 log "github.com/sirupsen/logrus"
2017 "github.com/spf13/cobra"
@@ -87,7 +84,7 @@ var buildCmd = &cobra.Command{
8784 },
8885}
8986
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 ) {
9188 br , exists := localCache .Location (pkg )
9289 if ! exists {
9390 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
124121 }
125122}
126123
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 ) {
128125 br , exists := localCache .Location (pkg )
129126 if ! exists {
130127 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) {
181178 cmd .Flags ().Bool ("report-github" , os .Getenv ("GITHUB_OUTPUT" ) != "" , "Report package build success/failure to GitHub Actions using the GITHUB_OUTPUT environment variable" )
182179}
183180
184- func getBuildOpts (cmd * cobra.Command ) ([]leeway.BuildOption , cache. LocalCache ) {
181+ func getBuildOpts (cmd * cobra.Command ) ([]leeway.BuildOption , * leeway. FilesystemCache ) {
185182 cm , _ := cmd .Flags ().GetString ("cache" )
186183 log .WithField ("cacheMode" , cm ).Debug ("configuring caches" )
187184 cacheLevel := leeway .CacheLevel (cm )
188185
189- var remoteCache cache. RemoteCache
186+ remoteCache := getRemoteCache ()
190187 switch cacheLevel {
191188 case leeway .CacheNone , leeway .CacheLocal :
192- remoteCache = remote . NewNoRemoteCache ()
189+ remoteCache = leeway. NoRemoteCache {}
193190 case leeway .CacheRemotePull :
194- remoteCache = & pullOnlyRemoteCache {C : remote . NewNoRemoteCache () }
191+ remoteCache = & pullOnlyRemoteCache {C : remoteCache }
195192 case leeway .CacheRemotePush :
196- remoteCache = & pushOnlyRemoteCache {C : remote . NewNoRemoteCache () }
193+ remoteCache = & pushOnlyRemoteCache {C : remoteCache }
197194 case leeway .CacheRemote :
198- remoteCache = remote .NewNoRemoteCache ()
199195 default :
200196 log .Fatalf ("invalid cache level: %s" , cacheLevel )
201197 }
@@ -216,7 +212,7 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
216212 }
217213 }
218214 log .WithField ("location" , localCacheLoc ).Debug ("set up local cache" )
219- localCache , err := local .NewFilesystemCache (localCacheLoc )
215+ localCache , err := leeway .NewFilesystemCache (localCacheLoc )
220216 if err != nil {
221217 log .Fatal (err )
222218 }
@@ -314,33 +310,33 @@ func getBuildOpts(cmd *cobra.Command) ([]leeway.BuildOption, cache.LocalCache) {
314310}
315311
316312type pushOnlyRemoteCache struct {
317- C cache .RemoteCache
313+ C leeway .RemoteCache
318314}
319315
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 )
322318}
323319
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 {
325321 return nil
326322}
327323
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 )
330326}
331327
332328type pullOnlyRemoteCache struct {
333- C cache .RemoteCache
329+ C leeway .RemoteCache
334330}
335331
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 )
338334}
339335
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 )
342338}
343339
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 {
345341 return nil
346342}
0 commit comments