Skip to content
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

Fix rollouts:create to handle backend regionality & other fixes #7862

Merged
merged 10 commits into from
Oct 29, 2024

Conversation

blidd-google
Copy link
Contributor

@blidd-google blidd-google commented Oct 22, 2024

Fixes the following issues:

  • Prompts user to select a region if multiple regions contain a backend with the given backend ID; if --force flag is passed and region is ambiguous, the command fails
  • Lists branches with autocomplete when no branch or commit is specified
  • Removes confirmation prompt after branch or commit is specified
  • Fixes short form flags (-b for --git-branch, -g for --git-commit, -i removed)
  • Sends request to stable v1beta API instead of v1alpha

@blidd-google blidd-google changed the title Fix rollouts:create to handle backend regionality Fix rollouts:create to handle backend regionality & other fixes Oct 24, 2024
@blidd-google blidd-google requested review from tonyjhuang, taeold and joehan and removed request for tonyjhuang and taeold October 24, 2024 20:29
Copy link
Contributor

@joehan joehan left a comment

Choose a reason for hiding this comment

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

Concerned about the breaking flag changes

}

location =
location || (await promptLocation(projectId, "Select a location to host your backend:\n"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these commands support noninteractive use cases? If so, we should double check this code - it seems like it will prompt even in noninteractive mode if there is no location.

const rootDir = await promptOnce({
name: "rootDir",
type: "input",
default: "/",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this default to . instead? / can easily be mistaken for an absolute path.

async function promptNewBackendId(
projectId: string,
location: string,
prompt: any,
Copy link
Contributor

Choose a reason for hiding this comment

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

Use a stronger type than any here

try {
await apphosting.getBackend(projectId, location, backendId);
} catch (err: any) {
if (err.status === 404) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ingrid recently added type safe helpers for getting status or message from an error (

export function getErrStatus(err: unknown, defaultStatus?: number): number {
) - this would be a good place to use them to silence these check warnings.

Applies throughout.

@@ -0,0 +1,482 @@
import * as clc from "colorette";
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional - this files has a mix of prompting functions and API calling functions. In the past, I've see this lead to really large and unwieldy files. If you'd like to get ahead of that, consider splitting this into backendPrompts.ts and backend.ts

@@ -7,13 +7,12 @@ import { createRollout } from "../apphosting/rollout";

export const command = new Command("apphosting:rollouts:create <backendId>")
.description("create a rollout using a build for an App Hosting backend")
.option("-l, --location <location>", "specify the region of the backend", "us-central1")
.option("-i, --id <rolloutId>", "id of the rollout (defaults to autogenerating a random id)", "")
.option("-l, --location <location>", "specify the region of the backend", "-")
Copy link
Contributor

Choose a reason for hiding this comment

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

These flag changes are breaking changes, and ideally should be part of the next major version., unless App Hosting has a strong argument for allowing breaks in minor versions.

@blidd-google
Copy link
Contributor Author

Concerned about the breaking flag changes

The apphosting:rollouts:create feature was added without announcement, so our team is okay with the risk of a breaking change in a minor CLI release given that the likelihood we actually break anybody is very low.

Copy link
Contributor

@taeold taeold left a comment

Choose a reason for hiding this comment

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

+1 for making this breaking change.

@blidd-google blidd-google enabled auto-merge (squash) October 29, 2024 15:33
@blidd-google blidd-google merged commit ec55947 into master Oct 29, 2024
44 of 45 checks passed
@nolafs
Copy link

nolafs commented Nov 23, 2024

I currently using version 13.27.0 and the manual rollout option is missing:

error: apphosting:rollouts:create is not a Firebase command

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.

4 participants