Skip to content

Commit 25ab1fd

Browse files
authored
Revert "Refactor cache and update provenance to v0.2 (#198)" (#201)
This reverts commit 292cb12.
1 parent 8d414fe commit 25ab1fd

24 files changed

+1009
-1718
lines changed

cmd/build.go

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -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

316312
type 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

332328
type 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
}

cmd/provenance-assert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ var provenanceAssertCmd = &cobra.Command{
7373
return nil
7474
}
7575

76-
failures = append(assertions.AssertBundle(env), failures...)
76+
failures = append(assertions.AssertEnvelope(env), failures...)
7777

7878
raw, err := base64.StdEncoding.DecodeString(env.Payload)
7979
if err != nil {

cmd/root.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,33 @@ func getBuildArgs() (leeway.Arguments, error) {
173173
return res, nil
174174
}
175175

176+
func getRemoteCache() leeway.RemoteCache {
177+
remoteCacheBucket := os.Getenv(EnvvarRemoteCacheBucket)
178+
remoteStorage := os.Getenv(EnvvarRemoteCacheStorage)
179+
if remoteCacheBucket != "" {
180+
switch remoteStorage {
181+
case "GCP":
182+
return leeway.GSUtilRemoteCache{
183+
BucketName: remoteCacheBucket,
184+
}
185+
case "AWS":
186+
rc, err := leeway.NewS3RemoteCache(remoteCacheBucket, nil)
187+
if err != nil {
188+
log.Fatalf("cannot access remote S3 cache: %v", err)
189+
}
190+
191+
return rc
192+
default:
193+
return leeway.GSUtilRemoteCache{
194+
BucketName: remoteCacheBucket,
195+
}
196+
}
197+
198+
}
199+
200+
return leeway.NoRemoteCache{}
201+
}
202+
176203
func addExperimentalCommand(parent, child *cobra.Command) {
177204
if os.Getenv("LEEWAY_EXPERIMENTAL") != "true" {
178205
return

go.mod

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ module github.com/gitpod-io/leeway
33
go 1.23
44

55
require (
6-
github.com/aws/aws-sdk-go-v2 v1.36.1
7-
github.com/aws/aws-sdk-go-v2/config v1.29.6
8-
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.59
9-
github.com/aws/aws-sdk-go-v2/service/s3 v1.75.4
6+
github.com/aws/aws-sdk-go-v2 v1.32.3
7+
github.com/aws/aws-sdk-go-v2/config v1.28.1
8+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.35
9+
github.com/aws/aws-sdk-go-v2/service/s3 v1.66.2
10+
github.com/aws/aws-sdk-go-v2/service/sts v1.32.3
1011
github.com/creack/pty v1.1.23
1112
github.com/disiqueira/gotree v1.0.0
1213
github.com/dop251/goja v0.0.0-20241024094426-79f3a7efcdbd
@@ -15,7 +16,7 @@ require (
1516
github.com/google/uuid v1.6.0
1617
github.com/gookit/color v1.5.4
1718
github.com/imdario/mergo v0.3.13
18-
github.com/in-toto/in-toto-golang v0.9.0
19+
github.com/in-toto/in-toto-golang v0.3.3
1920
github.com/karrick/godirwalk v1.17.0
2021
github.com/minio/highwayhash v1.0.2
2122
github.com/opencontainers/runc v1.1.10
@@ -25,45 +26,45 @@ require (
2526
github.com/sirupsen/logrus v1.9.3
2627
github.com/spf13/cobra v1.8.1
2728
github.com/stretchr/testify v1.9.0
28-
golang.org/x/mod v0.23.0
29-
golang.org/x/sync v0.11.0
29+
golang.org/x/mod v0.21.0
30+
golang.org/x/sync v0.8.0
3031
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
3132
gopkg.in/yaml.v3 v3.0.1
32-
sigs.k8s.io/bom v0.6.0
33+
sigs.k8s.io/bom v0.1.0
3334
)
3435

3536
require (
36-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.8 // indirect
37-
github.com/aws/aws-sdk-go-v2/credentials v1.17.59 // indirect
38-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.28 // indirect
39-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.32 // indirect
40-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.32 // indirect
41-
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.2 // indirect
42-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.32 // indirect
43-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.2 // indirect
44-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.5.6 // indirect
45-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.13 // indirect
46-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.13 // indirect
47-
github.com/aws/aws-sdk-go-v2/service/sso v1.24.15 // indirect
48-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.14 // indirect
49-
github.com/aws/aws-sdk-go-v2/service/sts v1.33.14 // indirect
50-
github.com/aws/smithy-go v1.22.2 // indirect
37+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.6 // indirect
38+
github.com/aws/aws-sdk-go-v2/credentials v1.17.42 // indirect
39+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.18 // indirect
40+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.22 // indirect
41+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.22 // indirect
42+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
43+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.22 // indirect
44+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 // indirect
45+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.4.3 // indirect
46+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.3 // indirect
47+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.18.3 // indirect
48+
github.com/aws/aws-sdk-go-v2/service/sso v1.24.3 // indirect
49+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.3 // indirect
50+
github.com/aws/smithy-go v1.22.0 // indirect
5151
github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 // indirect
52-
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
53-
github.com/cyphar/filepath-securejoin v0.2.3 // indirect
52+
github.com/coreos/go-systemd/v22 v22.5.0 // indirect
53+
github.com/cyphar/filepath-securejoin v0.3.4 // indirect
5454
github.com/davecgh/go-spew v1.1.1 // indirect
5555
github.com/dlclark/regexp2 v1.11.4 // indirect
5656
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
57-
github.com/godbus/dbus/v5 v5.0.6 // indirect
57+
github.com/godbus/dbus/v5 v5.1.0 // indirect
5858
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
5959
github.com/inconshreveable/mousetrap v1.1.0 // indirect
60-
github.com/moby/sys/mountinfo v0.5.0 // indirect
60+
github.com/kr/pretty v0.3.1 // indirect
61+
github.com/moby/sys/mountinfo v0.7.1 // indirect
62+
github.com/pkg/errors v0.9.1 // indirect
6163
github.com/pmezard/go-difflib v1.0.0 // indirect
62-
github.com/rogpeppe/go-internal v1.13.1 // indirect
63-
github.com/seccomp/libseccomp-golang v0.9.2-0.20220502022130-f33da4d89646 // indirect
64-
github.com/secure-systems-lab/go-securesystemslib v0.6.0 // indirect
64+
github.com/rogpeppe/go-internal v1.11.0 // indirect
65+
github.com/seccomp/libseccomp-golang v0.10.0 // indirect
6566
github.com/segmentio/backo-go v1.0.0 // indirect
66-
github.com/shibumi/go-pathspec v1.3.0 // indirect
67+
github.com/shibumi/go-pathspec v1.2.0 // indirect
6768
github.com/spf13/pflag v1.0.5 // indirect
6869
github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778 // indirect
6970
golang.org/x/crypto v0.31.0 // indirect

0 commit comments

Comments
 (0)