Skip to content

Commit ce0ec44

Browse files
Merge pull request #441 from depot/codex/explain-org-flag-header-usage
Make cache uploads org aware
2 parents 62f38fe + 613a7b1 commit ce0ec44

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ dist/
33
/cli
44
/bin
55
/depot
6+
/.gocache
67

78
node_modules
89

pkg/api/cache.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@ func newCacheServiceClient() cachev1connect.CacheServiceClient {
3030
// UploadCacheEntry uploads content to the Depot Cache service as a generic entry.
3131
// It uses a 3-step process: CreateEntry, HTTP PUT to presigned URL, FinalizeEntry.
3232
// If the entry already exists (content-addressed), it returns nil.
33-
func UploadCacheEntry(ctx context.Context, token, key string, content []byte) error {
33+
func UploadCacheEntry(ctx context.Context, token, orgID, key string, content []byte) error {
3434
client := newCacheServiceClient()
3535

3636
// Step 1: Create cache entry
37-
createResp, err := client.CreateEntry(ctx, WithAuthentication(connect.NewRequest(&cachev1.CreateEntryRequest{
37+
createResp, err := client.CreateEntry(ctx, WithAuthenticationAndOrg(connect.NewRequest(&cachev1.CreateEntryRequest{
3838
EntryType: "generic",
3939
Key: key,
40-
}), token))
40+
}), token, orgID))
4141
if err != nil {
4242
// Content-addressed: if already exists, skip upload
4343
if connect.CodeOf(err) == connect.CodeAlreadyExists {
@@ -74,11 +74,11 @@ func UploadCacheEntry(ctx context.Context, token, key string, content []byte) er
7474
}
7575

7676
// Step 3: Finalize the entry
77-
_, err = client.FinalizeEntry(ctx, WithAuthentication(connect.NewRequest(&cachev1.FinalizeEntryRequest{
77+
_, err = client.FinalizeEntry(ctx, WithAuthenticationAndOrg(connect.NewRequest(&cachev1.FinalizeEntryRequest{
7878
EntryId: createResp.Msg.EntryId,
7979
SizeBytes: int64(len(content)),
8080
UploadPartEtags: []string{etag},
81-
}), token))
81+
}), token, orgID))
8282
if err != nil {
8383
return fmt.Errorf("failed to finalize cache entry: %w", err)
8484
}

pkg/cmd/ci/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ This command is in beta and subject to change.`,
142142
cacheKey := fmt.Sprintf("patch/%s/%s", patch.mergeBase[:12], patchHash)
143143
fmt.Printf("Cache key: %s\n", cacheKey)
144144

145-
if err := api.UploadCacheEntry(ctx, tokenVal, cacheKey, []byte(patch.content)); err != nil {
145+
if err := api.UploadCacheEntry(ctx, tokenVal, orgID, cacheKey, []byte(patch.content)); err != nil {
146146
return fmt.Errorf("failed to upload patch: %w", err)
147147
}
148148
fmt.Println("Patch uploaded to Depot Cache")

0 commit comments

Comments
 (0)