-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat: add Flagship binding support #13139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
roerohan
wants to merge
18
commits into
cloudflare:main
Choose a base branch
from
roerohan:roerohan/flagship
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+273
−8
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
1412c56
[workers-utils] feat: add Flagship feature flag binding types and config
roerohan 1c08e92
[miniflare] feat: add Flagship remote-only plugin
roerohan 17b097b
[wrangler] feat: wire Flagship binding through deployment and dev pip…
roerohan 8756a6b
[wrangler] feat: add Flagship type generation and OAuth scopes
roerohan 48b61a1
chore: add changeset for Flagship binding support
roerohan f4b948a
Merge branch 'main' into roerohan/flagship
roerohan 1fc78cb
[miniflare] fix: flagship plugin getServices should always create ser…
roerohan a1a828c
[workers-utils] fix: add flagship to empty config defaults test expec…
roerohan 505ad9e
[workers-utils] fix: add flagship to safeBindings in validateUnsafeBi…
roerohan 0556a03
chore: fix lint and formatting issues
roerohan 07627ed
chore: bump changeset to minor for new feature
roerohan 8a3a1f7
[wrangler] fix: update OAuth scope snapshots for flagship scopes
roerohan 2c8a288
Merge branch 'main' into roerohan/flagship
roerohan 70b9069
[wrangler] fix: add flagship to type-generation test mock config
roerohan fe76547
[wrangler] fix: add FLAGS: Flags to type-generation test snapshots
roerohan 84f2895
Merge branch 'main' into roerohan/flagship
roerohan 7702b65
[wrangler] fix: restore missing 'Found Worker' lines in type-generati…
roerohan b47e65c
Merge branch 'main' into roerohan/flagship
roerohan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "miniflare": minor | ||
| "wrangler": minor | ||
| "@cloudflare/workers-utils": minor | ||
| --- | ||
|
|
||
| feat: add Flagship feature flag binding support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| import { z } from "zod"; | ||
| import { Worker_Binding } from "../../runtime"; | ||
| import { | ||
| getUserBindingServiceName, | ||
| Plugin, | ||
| ProxyNodeBinding, | ||
| remoteProxyClientWorker, | ||
| RemoteProxyConnectionString, | ||
| } from "../shared"; | ||
|
|
||
| const FlagshipSchema = z.object({ | ||
| app_id: z.string(), | ||
| remoteProxyConnectionString: z | ||
| .custom<RemoteProxyConnectionString>() | ||
| .optional(), | ||
| }); | ||
|
|
||
| export const FlagshipOptionsSchema = z.object({ | ||
| flagship: z.record(FlagshipSchema).optional(), | ||
| }); | ||
|
|
||
| export const FLAGSHIP_PLUGIN_NAME = "flagship"; | ||
|
|
||
| export const FLAGSHIP_PLUGIN: Plugin<typeof FlagshipOptionsSchema> = { | ||
| options: FlagshipOptionsSchema, | ||
| async getBindings(options) { | ||
| if (!options.flagship) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.flagship).map<Worker_Binding>( | ||
| ([name, config]) => ({ | ||
| name, | ||
| service: { | ||
| name: getUserBindingServiceName( | ||
| FLAGSHIP_PLUGIN_NAME, | ||
| name, | ||
| config.remoteProxyConnectionString | ||
| ), | ||
| }, | ||
| }) | ||
| ); | ||
| }, | ||
| getNodeBindings(options: z.infer<typeof FlagshipOptionsSchema>) { | ||
| if (!options.flagship) { | ||
| return {}; | ||
| } | ||
| return Object.fromEntries( | ||
| Object.keys(options.flagship).map((name) => [ | ||
| name, | ||
| new ProxyNodeBinding(), | ||
| ]) | ||
| ); | ||
| }, | ||
| async getServices({ options }) { | ||
| if (!options.flagship) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.flagship).map( | ||
| ([name, { remoteProxyConnectionString }]) => { | ||
| return { | ||
| name: getUserBindingServiceName( | ||
| FLAGSHIP_PLUGIN_NAME, | ||
| name, | ||
| remoteProxyConnectionString | ||
| ), | ||
| worker: remoteProxyClientWorker(remoteProxyConnectionString, name), | ||
| }; | ||
| } | ||
| ); | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 No tests included for flagship binding integration
Per the AGENTS.md and CONTRIBUTING.md guidelines, every non-trivial change should include tests. This PR adds a new binding type across multiple packages (miniflare plugin, config validation, type generation, deployment form, print bindings) but includes no test files. Existing bindings like Hello World have tests in
packages/miniflare/test/plugins/. Config validation changes typically have tests inpackages/workers-utils/src/config/__tests__/. The type generation changes have tests inpackages/wrangler/src/__tests__/type-generation/. At minimum, the miniflare plugin, config validation, and type generation should have corresponding tests.Was this helpful? React with 👍 or 👎 to provide feedback.