Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ dist/
/cli
/bin
/depot
/.gocache

node_modules

Expand Down
10 changes: 5 additions & 5 deletions pkg/api/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ func newCacheServiceClient() cachev1connect.CacheServiceClient {
// UploadCacheEntry uploads content to the Depot Cache service as a generic entry.
// It uses a 3-step process: CreateEntry, HTTP PUT to presigned URL, FinalizeEntry.
// If the entry already exists (content-addressed), it returns nil.
func UploadCacheEntry(ctx context.Context, token, key string, content []byte) error {
func UploadCacheEntry(ctx context.Context, token, orgID, key string, content []byte) error {
client := newCacheServiceClient()

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

// Step 3: Finalize the entry
_, err = client.FinalizeEntry(ctx, WithAuthentication(connect.NewRequest(&cachev1.FinalizeEntryRequest{
_, err = client.FinalizeEntry(ctx, WithAuthenticationAndOrg(connect.NewRequest(&cachev1.FinalizeEntryRequest{
EntryId: createResp.Msg.EntryId,
SizeBytes: int64(len(content)),
UploadPartEtags: []string{etag},
}), token))
}), token, orgID))
if err != nil {
return fmt.Errorf("failed to finalize cache entry: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/cmd/ci/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ This command is in beta and subject to change.`,
cacheKey := fmt.Sprintf("patch/%s/%s", patch.mergeBase[:12], patchHash)
fmt.Printf("Cache key: %s\n", cacheKey)

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