[wrangler] feat: add --secrets-file parameter to deploy and versions upload#10896
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
🦋 Changeset detectedLatest commit: ce22602 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
|
Fixed! I've restored the comment in commit 710a08c. The comment is now back on line 753: logpush: undefined, // both logpush and observability are not supported in versions uploadAll local tests pass. There are 2 macOS test failures in CI, but they appear to be unrelated flaky tests since my change only restored a comment. |
|
Fixed! I've updated the logic to always set Changes in commit 93e74d6:
This ensures that secrets not included in the file will be inherited from the previous version, making the secrets file truly additive. |
3f78336 to
0de7764
Compare
|
Can you rebase and fix the conflicts here? |
|
❌ Cannot revive Devin session - the session is too old. Please start a new session instead. |
0de7764 to
4f6b593
Compare
|
Happy to see this moving along and that you included the functionality for One important request - I'm feeding in secrets from another tool and would like to avoid writing anything to disk. Is there a way to accept the secrets content as a long string or to feed in on stdin like This would allow passing them as @petebacondarwin - any update on timeline for this to land? It will greatly simplify things for using Varlock with Cloudflare secrets |
|
This is an old PR that's quite stale so I'm going to close it for now. If you'd still like to land it feel free to re-open and get it back up to date with |
|
@penalosa @petebacondarwin - would really love to see this single step "deploy with secrets" functionality land. Anything I can do to help? I expect you're likely not taking external PRs much these days? |
|
Re-opening as I would like to try landing this. |
fc2aa9e to
0c8e830
Compare
|
✅ All changesets look good |
f242028 to
6e255bf
Compare
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
- Set keepSecrets: true unconditionally (regardless of secretsFile) - Remove keepBindings assignment when secretsFile is provided - createWorkerUploadForm() automatically adds keep_bindings when keepSecrets is true - Secrets from file are now additive to existing secrets (matching versions secret bulk behavior) - Update tests to expect correct keep_bindings order: ['secret_text', 'secret_key'] Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
- Add --secrets-file argument to deploy command options - Parse secrets file and add to rawBindings in deploy implementation - Set keepSecrets: true to inherit existing secrets (additive behavior) - Add comprehensive unit tests for deploy with secrets file - Update changeset to document both deploy and versions upload commands Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
- Set keepSecrets based on keepVars OR secretsFile (not unconditional) - Remove incorrect test that expected keepSecrets=true by default - Preserves backward compatibility while enabling --secrets-file feature Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
Co-Authored-By: pbacondarwin@cloudflare.com <pete@bacondarwin.com>
…ctored API - Create __tests__/deploy/secrets.test.ts with 5 tests for --secrets-file - Fix deploy.ts to add secrets to the bindings map instead of rawBindings, since createWorkerUploadForm now Omits rawBindings from CfWorkerInit - Remove unused WorkerMetadataBinding import from deploy.ts
Apply the same fix as deploy.ts — add secrets to the bindings map instead of setting rawBindings on CfWorkerInit, which no longer has that property after the main branch refactor.
Use captureRequestsFrom() to capture requests and assert on them after runWrangler() completes, instead of placing expect() calls inside MSW handlers. Also destructure expect from test context per wrangler conventions.
b1ebbdf to
e13be2a
Compare
|
Codeowners approval required for this PR:
Show detailed file reviewers |
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Generally looks good to me 🙂
I've just left some minor non-blocking comments.
Also one question I have, could/should we support multiple secret files as well?
e.g.
wrangler deploy --secrets-file env.base --secrets-file .env.production
Adds a
--secrets-fileparameter to bothwrangler deployandwrangler versions upload, allowing secrets to be uploaded alongside Worker code in a single operation.Changes
New CLI option:
--secrets-file <path>Both commands accept a path to a JSON or
.envfile containing secrets. The file is parsed using the existingparseBulkInputToObject()from the secrets module (same parser used bywrangler versions secret bulk).Implementation details:
bindingsmap assecret_textentries (deploy/deploy.ts,versions/upload.ts)wrangler deploy: setskeepSecrets: truewhen--secrets-fileis provided (or when--keep-varsis set), so existing secrets not in the file are preservedwrangler versions upload:keepSecretsremains unconditionallytrue(existing behavior — secrets are always inherited)--secrets-filecross-references--keep-secretsfor discoverabilityFiles changed:
packages/wrangler/src/deploy/index.ts--secrets-fileoptionpackages/wrangler/src/deploy/deploy.tskeepSecretspackages/wrangler/src/versions/upload.ts--secrets-fileoption, parse secrets file, add to bindingspackages/wrangler/src/__tests__/deploy/secrets.test.tsdeploy --secrets-filepackages/wrangler/src/__tests__/versions/upload.test.tsversions upload --secrets-file.changeset/secrets-file-versions-upload.md