Skip to content

feat: add Uzumibi::Secret.get for Cloudflare secrets#36

Merged
udzura merged 2 commits into
mrubyedge:masterfrom
itojum:features/add-cloudflare-uzumibi-secret
May 25, 2026
Merged

feat: add Uzumibi::Secret.get for Cloudflare secrets#36
udzura merged 2 commits into
mrubyedge:masterfrom
itojum:features/add-cloudflare-uzumibi-secret

Conversation

@itojum
Copy link
Copy Markdown
Contributor

@itojum itojum commented May 25, 2026

Overview

Add Uzumibi::Secret.get(key) to access Cloudflare Workers secret bindings from mruby code.

Changes

  • uzumibi-cloudflare-ext/src/lib.rs: Add cf_secret_get host function and register Uzumibi::Secret class with .get method
  • uzumibi-cli/templates/cloudflare/__features__/enable-external/src/index.js: Add uzumibi_cf_secret_get host import that reads from the Workers env object
  • uzumibi-on-cloudflare-spike/src/index.js: Same host import addition (spike project)

Usage

value = Uzumibi::Secret.get("MY_SECRET_KEY")

Returns the value as a String, or nil if the key is not found. Works for both wrangler secret put secrets and [vars] in wrangler.toml, as Cloudflare Workers exposes all env bindings via the same env object.

What I did

Deployed to Cloudflare and confirmed that secret bindings (set via wrangler secret put) can be accessed.

Out of Scope

  • Uzumibi::Secret.get implementation on platforms other than Cloudflare.

itojum added 2 commits May 25, 2026 17:58
The Cloudflare environment variable limit is 5KB, so I have reduced the
buffer size to 8KB.
@itojum itojum changed the title Features/add cloudflare uzumibi secret feat: add Uzumibi::Secret.get for Cloudflare secrets May 25, 2026
Copy link
Copy Markdown
Contributor

@udzura udzura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! I'll release the new version and reflect this to our templates!

(Please give me a few minutes, sorry 🙏 )

@udzura udzura merged commit c2ec07b into mrubyedge:master May 25, 2026
6 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