Implement Cloudflare cloud adapter#747
Conversation
Greptile SummaryReplaces the Cloudflare cloud stub with a full REST API adapter covering R2 buckets, D1 databases, Queues, and Cloudflare Tunnels. The adapter adds account discovery with pagination, dry-run support, Cloudflare envelope error handling, prefixed instance IDs, and
Confidence Score: 4/5The adapter is substantially complete and the previous round of blocking issues (tunnel secret loss, missing pagination, R2 nested array mismatch) have all been addressed. The remaining concerns are non-blocking: the tunnelStatus catch-all can misreport an errored tunnel as provisioning, and cfListAll may silently truncate lists on any CF endpoint that omits total_pages from its result_info. The tunnelStatus catch-all returning 'provisioning' for unknown statuses (including Cloudflare's real 'errored' status) and cfListAll's silent truncation when total_pages is absent are both present-but-non-critical defects that could affect operator experience in production but don't corrupt data or block the primary provisioning flow. packages/cloud/cloudflare/src/index.ts — specifically tunnelStatus (line 479) and the cfListAll pagination termination condition (line 274). Important Files Changed
Sequence DiagramsequenceDiagram
participant Caller
participant Adapter as cloud-cloudflare
participant CF as Cloudflare REST API
Caller->>Adapter: "connect(ctx, { accountId? })"
alt accountId provided
Adapter->>CF: GET /accounts/:id
CF-->>Adapter: "{ result: { id, name } }"
else no accountId
loop cfListAll pages
Adapter->>CF: "GET /accounts?page=N&per_page=100"
CF-->>Adapter: "{ result: [...], result_info: { total_pages } }"
end
end
Adapter-->>Caller: "{ accountId }"
Caller->>Adapter: provision(ctx, spec, config)
Adapter->>Adapter: resourceTypeFor(spec, config)
Adapter->>Adapter: quote(ctx, spec, config)
alt dryRun
Adapter-->>Caller: dryRunInstance
else live
Adapter->>CF: "POST /accounts/:id/{r2/buckets|d1/database|queues|cfd_tunnel}"
CF-->>Adapter: "{ result: { ..., tunnel_token? } }"
Adapter-->>Caller: Instance (metadata.cloudflareTunnelToken if tunnel)
end
Caller->>Adapter: list(ctx, config)
par all resource types
Adapter->>CF: "GET /accounts/:id/r2/buckets?page=N"
and
Adapter->>CF: "GET /accounts/:id/d1/database?page=N"
and
Adapter->>CF: "GET /accounts/:id/queues?page=N"
and
Adapter->>CF: "GET /accounts/:id/cfd_tunnel?page=N"
end
CF-->>Adapter: paginated results
Adapter-->>Caller: Instance[]
Caller->>Adapter: destroy(ctx, instanceId, config)
Adapter->>Adapter: parseResourceId(instanceId)
Adapter->>CF: "DELETE /accounts/:id/{resource}/:nativeId"
CF-->>Adapter: 200 / 204
Reviews (3): Last reviewed commit: "Fix Cloudflare review follow-ups" | Re-trigger Greptile |
|
Addressed the Greptile findings in
Validation passed locally with |
|
Addressed the remaining Cloudflare adapter review threads in
Validation on the pushed head:
GitHub |
|
🤖 Auto-rebase: The branch was rebased successfully locally but could not be pushed to the fork. Please enable 'Allow edits from maintainers' in the PR settings, or rebase manually: |
Summary
Validation