-
Notifications
You must be signed in to change notification settings - Fork 1.8k
feat(hosting): hosting CLI owns the deploy flags; --hostname names the GCP service #6937
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
Kastier1
wants to merge
4
commits into
main
Choose a base branch
from
simon/deploy-shim-and-gcp-service-name
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.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
dcea987
feat(hosting): hosting CLI owns the deploy flags; --hostname names th…
Kastier1 02085be
fix CI: isolate env in the deploy shim test, tolerate an older hostin…
Kastier1 d7df466
keep deploy working on a hosting CLI older than deploy_options
Kastier1 cc7d482
tighten the drift guard, and let its test file load without the module
Kastier1 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 @@ | ||
| `reflex deploy` is now a thin shim over the hosting CLI's deploy: it declares only the framework-owned flags (`--exclude-from-backend`, `--ssr`) and adopts every hosting flag from `reflex_cli.v2.deploy_options`, forwarding parsed values as keyword arguments. New hosting deploy flags therefore ship with a hosting-cli release alone, without a reflex release. A hosting CLI too old to own that module keeps working: the flags fall back to a baseline copy in the framework, which is removed once the dependency floor moves to a release that ships the module. |
1 change: 1 addition & 0 deletions
1
packages/reflex-hosting-cli/news/+deploy-options-export.feature.md
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 @@ | ||
| The deploy command's hosting-owned click options are now exported from `reflex_cli.v2.deploy_options.deploy_options()`. `reflex deploy` adopts them from the installed hosting CLI and forwards parsed values as keyword arguments, so adding a hosting flag is one change here and ships with a hosting-cli release alone — no framework release required. |
1 change: 1 addition & 0 deletions
1
packages/reflex-hosting-cli/news/+gcp-service-name-from-hostname.feature.md
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 @@ | ||
| On the deploy that first lands an app on GCP, `--hostname` now doubles as the app's Cloud Run service name, so the service in the customer's console reads like the app's URL instead of `app-<uuid>`. A hostname the service-name grammar refuses (leading digit, over 49 characters, or the reserved `app-<uuid>` shape) is skipped with a note and the server generates a name from the app name; later GCP deploys never send one, since the name is pinned to the live service. |
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
135 changes: 135 additions & 0 deletions
135
packages/reflex-hosting-cli/src/reflex_cli/v2/deploy_options.py
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,135 @@ | ||
| """The deploy command's click options, owned by the hosting CLI. | ||
|
|
||
| ``reflex deploy`` is a thin shim: it declares only the options the framework | ||
| itself consumes (export/compile concerns) and adopts everything else from | ||
| :func:`deploy_options`, forwarding the parsed values into | ||
| :func:`reflex_cli.v2.cli.deploy` as keyword arguments. Adding a hosting flag is | ||
| therefore one change here — an option whose name matches the ``deploy()`` | ||
| parameter it feeds — and ships with a hosting-cli release alone, no framework | ||
| release required. | ||
| """ | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import click | ||
|
|
||
| DEPLOY_STRATEGIES = ["immediate", "rolling", "bluegreen", "canary"] | ||
|
|
||
|
|
||
| def deploy_options() -> list[click.Parameter]: | ||
| """The hosting-owned click options for the deploy command. | ||
|
|
||
| Every option's parameter name matches the keyword argument of | ||
| :func:`reflex_cli.v2.cli.deploy` it is forwarded to. | ||
|
|
||
| Returns: | ||
| The options, in the order they should appear in ``--help``. | ||
|
|
||
| """ | ||
| return [ | ||
| click.Option( | ||
| ["--app-name", "app_name"], | ||
| help="The name of the app to deploy.", | ||
| ), | ||
| click.Option( | ||
| ["--app-id", "app_id"], | ||
| help="The ID of the app to deploy.", | ||
| ), | ||
| click.Option( | ||
| ["-r", "--region", "regions"], | ||
| multiple=True, | ||
| help="The regions to deploy to. `reflex cloud regions` For multiple " | ||
| "envs, repeat this option, e.g. --region sjc --region iad", | ||
| ), | ||
| click.Option( | ||
| ["--env", "envs"], | ||
| multiple=True, | ||
| help="The environment variables to set: <key>=<value>. For multiple " | ||
| "envs, repeat this option, e.g. --env k1=v2 --env k2=v2.", | ||
| ), | ||
| click.Option( | ||
| ["--vmtype", "vmtype"], | ||
| help="Vm type id. Run `reflex cloud vmtypes` to get options.", | ||
| ), | ||
| click.Option( | ||
| ["--min-instances", "min_instances"], | ||
| type=int, | ||
| help="The minimum number of instances to keep running. Left " | ||
| "unchanged when omitted. Only supported on apps deployed to " | ||
| "Google Cloud.", | ||
| ), | ||
| click.Option( | ||
| ["--max-instances", "max_instances"], | ||
| type=int, | ||
| help="The maximum number of instances to scale out to. Left " | ||
| "unchanged when omitted. Only supported on apps deployed to " | ||
| "Google Cloud.", | ||
| ), | ||
| click.Option( | ||
| ["--hostname", "hostname"], | ||
| help="The hostname of the frontend. On the deploy that first lands " | ||
| "the app on GCP, it also names the app's Cloud Run service.", | ||
| ), | ||
| click.Option( | ||
| ["--provider", "provider"], | ||
| help="The hosting provider to deploy to: 'reflex-cloud' (default) " | ||
| "or 'gcp' (a GCP account connected to your org, Enterprise tier). " | ||
| "When omitted and GCP is connected, you'll be prompted in " | ||
| "interactive mode. Deploys through Reflex Cloud either way; for an " | ||
| "unmanaged deploy run under your own gcloud credentials, see " | ||
| "`reflex cloud gcp-standalone`.", | ||
| ), | ||
| click.Option( | ||
| ["--gcp-connection", "gcp_connection"], | ||
| help="Which of your organization's GCP connections to deploy " | ||
| "through, by name. Run `reflex cloud providers connections` to " | ||
| "list them. Only valid with --provider gcp; omitted keeps the app " | ||
| "on the connection it already has, or your organization's default " | ||
| "the first time it deploys to GCP.", | ||
| ), | ||
| click.Option( | ||
| ["--full-deploy/--no-full-deploy", "full_deploy"], | ||
| default=None, | ||
| help="Serve the frontend from the provider's own container, on the " | ||
| "same origin as the backend, instead of Reflex's CDN. GCP only, " | ||
| "Enterprise tier. Omitted leaves the app's hosting mode unchanged; " | ||
| "changing it stops a running app so this deploy brings it back up " | ||
| "in the new mode.", | ||
| ), | ||
| click.Option( | ||
| ["--strategy", "strategy"], | ||
| type=click.Choice(DEPLOY_STRATEGIES), | ||
| help="How the new version rolls out. Defaults to the app's last " | ||
| "strategy, or 'immediate'.", | ||
| ), | ||
| click.Option( | ||
| ["--description", "deployment_description"], | ||
| help="An optional note recorded on this deployment and shown in " | ||
| "`reflex cloud apps history`.", | ||
| ), | ||
| click.Option( | ||
| ["--interactive/--no-interactive", "interactive"], | ||
| default=True, | ||
| help="Whether to list configuration options and ask for confirmation.", | ||
| ), | ||
| click.Option( | ||
| ["--envfile", "envfile"], | ||
| help="The path to an env file to use. Will override any envs set manually.", | ||
| ), | ||
| click.Option( | ||
| ["--project", "project"], | ||
| help="project id to deploy to", | ||
| ), | ||
| click.Option( | ||
| ["--project-name", "project_name"], | ||
| help="The name of the project to deploy to.", | ||
| ), | ||
| click.Option( | ||
| ["--token", "token"], | ||
| help="token to use for auth", | ||
| ), | ||
| click.Option( | ||
| ["--config-path", "--config", "config_path"], | ||
| help="path to the config file", | ||
| ), | ||
| ] |
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.
Uh oh!
There was an error while loading. Please reload this page.