Skip to content

Commit fb93b72

Browse files
authored
Merge pull request #321 from depot/revert-320-fix/bake-sboms-s3-cache
Revert "fix: add SBOM and S3 caching secrets"
2 parents 49e1e08 + f9fd42e commit fb93b72

File tree

4 files changed

+5
-78
lines changed

4 files changed

+5
-78
lines changed

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ require (
77
buf.build/gen/go/depot/api/protocolbuffers/go v1.32.0-20240221184445-e8316610338f.1
88
connectrpc.com/connect v1.15.0
99
github.com/adrg/xdg v0.4.0
10-
github.com/aws/aws-sdk-go-v2/config v1.15.5
1110
github.com/briandowns/spinner v1.18.1
1211
github.com/charmbracelet/bubbles v0.16.1
1312
github.com/charmbracelet/bubbletea v0.24.2
@@ -65,6 +64,7 @@ require (
6564
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
6665
github.com/atotto/clipboard v0.1.4 // indirect
6766
github.com/aws/aws-sdk-go-v2 v1.16.3 // indirect
67+
github.com/aws/aws-sdk-go-v2/config v1.15.5 // indirect
6868
github.com/aws/aws-sdk-go-v2/credentials v1.12.0 // indirect
6969
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.4 // indirect
7070
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.10 // indirect

Diff for: pkg/buildx/bake/buildflags/cache.go

-71
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
package buildflags
22

33
import (
4-
"context"
54
"encoding/csv"
65
"encoding/json"
76
"maps"
8-
"os"
9-
"strconv"
107
"strings"
118

12-
awsconfig "github.com/aws/aws-sdk-go-v2/config"
139
"github.com/moby/buildkit/client"
1410
"github.com/pkg/errors"
1511
"github.com/zclconf/go-cty/cty"
@@ -187,9 +183,6 @@ func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
187183
return nil
188184
}
189185
for _, entry := range entries {
190-
addGithubToken(entry)
191-
addAwsCredentials(entry)
192-
193186
out := client.CacheOptionsEntry{
194187
Type: entry.Type,
195188
Attrs: map[string]string{},
@@ -201,67 +194,3 @@ func CreateCaches(entries []*CacheOptionsEntry) []client.CacheOptionsEntry {
201194
}
202195
return outs
203196
}
204-
205-
func addGithubToken(ci *CacheOptionsEntry) {
206-
if ci.Type != "gha" {
207-
return
208-
}
209-
version, ok := ci.Attrs["version"]
210-
if !ok {
211-
// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L19
212-
if v, ok := os.LookupEnv("ACTIONS_CACHE_SERVICE_V2"); ok {
213-
if b, err := strconv.ParseBool(v); err == nil && b {
214-
version = "2"
215-
}
216-
}
217-
}
218-
if _, ok := ci.Attrs["token"]; !ok {
219-
if v, ok := os.LookupEnv("ACTIONS_RUNTIME_TOKEN"); ok {
220-
ci.Attrs["token"] = v
221-
}
222-
}
223-
if _, ok := ci.Attrs["url_v2"]; !ok && version == "2" {
224-
// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L34-L35
225-
if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
226-
ci.Attrs["url_v2"] = v
227-
}
228-
}
229-
if _, ok := ci.Attrs["url"]; !ok {
230-
// https://github.com/actions/toolkit/blob/2b08dc18f261b9fdd978b70279b85cbef81af8bc/packages/cache/src/internal/config.ts#L28-L33
231-
if v, ok := os.LookupEnv("ACTIONS_CACHE_URL"); ok {
232-
ci.Attrs["url"] = v
233-
} else if v, ok := os.LookupEnv("ACTIONS_RESULTS_URL"); ok {
234-
ci.Attrs["url"] = v
235-
}
236-
}
237-
}
238-
239-
func addAwsCredentials(ci *CacheOptionsEntry) {
240-
if ci.Type != "s3" {
241-
return
242-
}
243-
_, okAccessKeyID := ci.Attrs["access_key_id"]
244-
_, okSecretAccessKey := ci.Attrs["secret_access_key"]
245-
// If the user provides access_key_id, secret_access_key, do not override the session token.
246-
if okAccessKeyID && okSecretAccessKey {
247-
return
248-
}
249-
ctx := context.TODO()
250-
awsConfig, err := awsconfig.LoadDefaultConfig(ctx)
251-
if err != nil {
252-
return
253-
}
254-
credentials, err := awsConfig.Credentials.Retrieve(ctx)
255-
if err != nil {
256-
return
257-
}
258-
if !okAccessKeyID && credentials.AccessKeyID != "" {
259-
ci.Attrs["access_key_id"] = credentials.AccessKeyID
260-
}
261-
if !okSecretAccessKey && credentials.SecretAccessKey != "" {
262-
ci.Attrs["secret_access_key"] = credentials.SecretAccessKey
263-
}
264-
if _, ok := ci.Attrs["session_token"]; !ok && credentials.SessionToken != "" {
265-
ci.Attrs["session_token"] = credentials.SessionToken
266-
}
267-
}

Diff for: pkg/buildx/build/build.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
401401
supportsAttestations := true
402402
if len(attests) > 0 {
403403
for k, v := range attests {
404-
so.FrontendAttrs["attest:"+k] = v
404+
so.FrontendAttrs[k] = v
405405
}
406406
}
407407
if _, ok := opt.Attests["attest:provenance"]; !ok && supportsAttestations {

Diff for: pkg/helpers/gha.go

+3-5
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ import "os"
77
func FixGitHubActionsCacheEnv() {
88
original := os.Getenv("UPSTREAM_ACTIONS_CACHE_URL")
99

10-
if original != "" {
11-
os.Setenv("ACTIONS_CACHE_URL", original)
10+
if original == "" {
11+
original = os.Getenv("GACTIONSCACHE_URL")
1212
}
1313

14-
original = os.Getenv("UPSTREAM_ACTIONS_RESULTS_URL")
15-
1614
if original != "" {
17-
os.Setenv("ACTIONS_RESULTS_URL", original)
15+
os.Setenv("ACTIONS_CACHE_URL", original)
1816
}
1917
}

0 commit comments

Comments
 (0)