Skip to content

Add per-project R2 firmware bucket overrides - #15

Merged
JamesSmartCell merged 1 commit into
masterfrom
cursor/firmware-per-project-buckets-4693
Nov 19, 2026
Merged

JamesSmartCell merged 1 commit into
masterfrom
cursor/firmware-per-project-buckets-4693

Conversation

@JamesSmartCell

Copy link
Copy Markdown
Owner

Summary

Adds generic per-project R2 firmware bucket support so zigbee-gateway can upload to / serve from a dedicated bucket, while GarageDoor/Web3E keep existing global defaults.

Design

Per-project env overrides (project zigbee-gateway → suffix ZIGBEE_GATEWAY):

R2_FIRMWARE_BUCKET_NAME__ZIGBEE_GATEWAY=esp-firmware
R2_FIRMWARE_PUBLIC_URL__ZIGBEE_GATEWAY=https://pub-862b54f8a0134f8d8276f74732be8015.r2.dev

Optional bucket-scoped credentials (fall back to global R2_*):

R2_ACCESS_KEY_ID__ZIGBEE_GATEWAY=...
R2_SECRET_ACCESS_KEY__ZIGBEE_GATEWAY=...
R2_ACCOUNT_ID__ZIGBEE_GATEWAY=...

Resolution order: per-project override → global R2_FIRMWARE_* → R2_BUCKET_NAME / R2_PUBLIC_URL.

Global R2_FIRMWARE_BUCKET_NAME / R2_FIRMWARE_PUBLIC_URL are not repurposed.

POST /api/firmware/:project uses uploadFirmwareToR2(project, ...), so GET /api/firmware/zigbee-gateway/latest returns the public URL from the new bucket with sha256 / size.

Pi env lines for Rob

R2_FIRMWARE_BUCKET_NAME__ZIGBEE_GATEWAY=esp-firmware
R2_FIRMWARE_PUBLIC_URL__ZIGBEE_GATEWAY=https://pub-862b54f8a0134f8d8276f74732be8015.r2.dev

If the R2 API token for esp-firmware is bucket-scoped (does not share the camera/global token), also add:

R2_ACCESS_KEY_ID__ZIGBEE_GATEWAY=<secret>
R2_SECRET_ACCESS_KEY__ZIGBEE_GATEWAY=<secret>
# optional if different account:
# R2_ACCOUNT_ID__ZIGBEE_GATEWAY=<account-id>

Leave existing R2_FIRMWARE_BUCKET_NAME / R2_FIRMWARE_PUBLIC_URL as-is for other projects.

Tests

  • Extended cloudflare-r2-url coverage for per-project bucket/URL/creds and GarageDoor fallback
  • Firmware API upload + /latest for zigbee-gateway public URL
  • Full suite green locally (266 tests)

Do not merge until Rob has set the Pi env (master auto-deploys).

Open in Web Open in Cursor 

Allow firmware projects to use dedicated R2 buckets via
R2_FIRMWARE_BUCKET_NAME__<PROJECT> / R2_FIRMWARE_PUBLIC_URL__<PROJECT>
(and optional per-bucket credentials), keeping global R2_FIRMWARE_* as
defaults so GarageDoor/Web3E behaviour is unchanged. zigbee-gateway uses
esp-firmware + the documented public URL.

Co-authored-by: James Brown <JamesSmartCell@users.noreply.github.com>
@JamesSmartCell
JamesSmartCell merged commit 76e3b3b into master Nov 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants